Direct audio transfer from Android 2.x

I need to play live on devices with versions 2.x and later. It says that it’s not possible to play live broadcasts on devices with Android 2.x.

What are the options here? I am particularly interested in streaming audio - which format should I choose and in combination with which protocol?

PS I tried Vitamio - I do not want clients to download third-party libraries.

UPD

+7
source share
2 answers

try this example for streaming RTSP (the URL must support RTSP) to change the video code to support only audio

public class MultimediaActivity extends Activity { private static final String RTSP = "rtsp://url here"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multimedia); //***VideoView to video element inside Multimedia.xml file VideoView videoView = (VideoView) findViewById(R.id.video); Log.v("Video", "***Video to Play:: " + RTSP); MediaController mc = new MediaController(this); mc.setAnchorView(videoView); Uri video = Uri.parse(RTSP); videoView.setMediaController(mc); videoView.setVideoURI(video); videoView.start(); } } 

EDIT:

Direct audio transfer using MediaPlayer in Android Direct audio transfer in Android and from 1.6 sdk onward has become so simple. The setDataSource () API directly passes the URL and the sound will play without any problems.

Full snippet of code

  public class AudioStream extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String url = "http://www.songblasts.com/songs/hindi/t/three-idiots/01-Aal_Izz_Well-(SongsBlasts.Com).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 mediaplayer e = " + e); } } } 
+3
source

You can use the RTSP protocol supported by the native Android media player.

  player = new MediaPlayer(); player.reset(); player.setDataSource(intent.getStringExtra("Path")); player.prepare(); player.setOnPreparedListener(new OnPreparedListener() { public void onPrepared(MediaPlayer mp) { player.start(); } }); 

Where will be your rtsp audio streaming url.

0
source

All Articles