How to stream audio from one Android device to another Android device Via Bluetooth?

后端 未结 5 1124
梦毁少年i
梦毁少年i 2020-12-12 18:11

Is it possible to stream audio over bluetooth? During my research I found that is it only possible using A2DP(Advanced Audio Distribution Profile). And does eve

5条回答
  •  醉话见心
    2020-12-12 19:13

    Try using following code snippet:

        public class AudioStream extends Activity {
    
     @Override
     public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      String url = "http://www.example.mp3";
      MediaPlayer mp = new MediaPlayer();
      try {
       mp.setDataSource(url);
       mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
       mp.prepare();
       mp.start();
      } catch (Exception e) {
       Log.i("Exception", "Exception in streaming = " + e);
      }
     }
    }
    

提交回复
热议问题