I try to make a live stream on Android. I tried lots of ways, but none of them worked. How can I do it?
This is example of RTSP:
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(KralStream.getTvStreamUrl().toString());
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepareAsync();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setLooping(true);
Exeption :05-26 10:22:46.186:
ERROR/MediaPlayerService(10157):
create PVPlayer 05-26 10:23:06.382:
ERROR/PlayerDriver(10157): Command
PLAYER_INIT completed with an error or
info -1 05-26 10:23:06.382:
ERROR/MediaPlayer(23800): error (1,
-1) 05-26 10:23:06.382: ERROR/MediaPlayer(23800): Error (1,-1)
RTSP:
VideoView videoView = (VideoView)findViewById(R.id.videoView1);
Uri uri = Uri.parse("rtsp://strm-3.tr.medianova.tv/rkraltv/rkraltv");
videoView.setVideoURI(uri);
videoView.start();
It gives this message:
"Sorry, this video
cannot ve played." Exeptions;05-26
10:40:08.979:
ERROR/MediaPlayerService(10157):
create PVPlayer 05-26 10:40:09.188:
INFO/ActivityManager(10163): Displayed
activity
com.giantrabbit.nagare/.KralTvNow: 433
ms (total 433 ms) 05-26 10:40:11.702:
WARN/PowerManagerService(10163): Timer
0x3->0x3|0x1 05-26 10:40:29.061:
WARN/MediaPlayer(24284): info/warning
(1, 26) 05-26 10:40:29.061:
INFO/MediaPlayer(24284): Info (1,26)
05-26 10:40:29.100:
ERROR/PlayerDriver(10157): Command
PLAYER_INIT completed with an error or
info -1 05-26 10:40:29.104:
ERROR/MediaPlayer(24284): error (1,
-1) 05-26 10:40:29.108: ERROR/MediaPlayer(24284): Error (1,-1)
RTSP:
mPreview = (SurfaceView) findViewById(R.id.surface);
holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
extras = getIntent().getExtras();
public void play() {
try {
Uri video = KralStream.getTvStreamUrl();
Toast.makeText(this, video.toString(), Toast.LENGTH_SHORT).show();
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
}
catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}
}
Exeption:
05-26 10:36:57.589:
ERROR/MediaPlayerService(10157):
create PVPlayer 05-26 10:37:20.542:
ERROR/PlayerDriver(10157): Command
PLAYER_INIT completed with an error or
info -1 05-26 10:37:20.542:
ERROR/MediaPlayer(24240): error (1,
-1) 05-26 10:37:20.565: WARN/PlayerDriver(10157):
PVMFInfoErrorHandlingComplete 05-26
10:37:20.682:
ERROR/MediaPlayerDemo(24240): error:
Prepare failed.: status=0x1 05-26
10:37:20.682:
ERROR/MediaPlayerDemo(24240):
java.io.IOException: Prepare failed.:
status=0x1 05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.media.MediaPlayer.prepare(Native
Method) 05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
com.giantrabbit.nagare.KralTvNow.play(KralTvNow.java:162)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
com.giantrabbit.nagare.KralTvNow.surfaceCreated(KralTvNow.java:215)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.SurfaceView.updateWindow(SurfaceView.java:536)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.SurfaceView.dispatchDraw(SurfaceView.java:339)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewGroup.drawChild(ViewGroup.java:1638)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewGroup.drawChild(ViewGroup.java:1638)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.View.draw(View.java:6796)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.widget.FrameLayout.draw(FrameLayout.java:352)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewGroup.drawChild(ViewGroup.java:1640)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.View.draw(View.java:6796)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.widget.FrameLayout.draw(FrameLayout.java:352)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1894)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewRoot.draw(ViewRoot.java:1407)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.os.Handler.dispatchMessage(Handler.java:99)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.os.Looper.loop(Looper.java:123)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
android.app.ActivityThread.main(ActivityThread.java:4627)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
java.lang.reflect.Method.invokeNative(Native
Method) 05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
java.lang.reflect.Method.invoke(Method.java:521)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
05-26 10:37:20.682:
ERROR/MediaPlayerDemo(24240): at
dalvik.system.NativeStart.main(Native
Method) 05-26 10:37:20.737:
INFO/MediaPlayer(24240): Info (1,26)
05-26 10:37:20.737:
ERROR/MediaPlayer(24240): Error (1,-1)
05-26 10:37:20.868:
INFO/ActivityManager(10163): Displayed
activity
com.giantrabbit.nagare/.KralTvNow:
25864 ms (total 25864 ms) 05-26
10:37:23.777:
WARN/PowerManagerService(10163): Timer
0x3->0x3|0x1
This is an example of HTTP:
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource("http://ikral.garantisistem.com:1935/ikral/smil:kral.smil/playlist.m3u8");
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepareAsync();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setLooping(true);
Exception:
05-26 10:16:24.276:
ERROR/MediaPlayerService(10157):
create PVPlayer 05-26 10:16:24.292:
ERROR/(10157): IIIIIII Inside
Constructor of
PVMFMemoryBufferWriteDataStreamImpl
05-26 10:16:24.346:
INFO/PlayerDriver(10157): buffering
(100) 05-26 10:16:24.346:
ERROR/(10157): IIIIIII Inside
Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.346: ERROR/(10157):
IIIIIII Inside Constructor of
PVMFMemoryBufferReadDataStreamImpl
05-26 10:16:24.350:
WARN/MediaPlayer(23736): info/warning
(1, 26) 05-26 10:16:24.354:
ERROR/PlayerDriver(10157): Command
PLAYER_INIT completed with an error or
info -10 05-26 10:16:24.354:
ERROR/MediaPlayer(23736): error (-10,
-10) 05-26 10:16:24.354: WARN/PlayerDriver(10157):
PVMFInfoErrorHandlingComplete 05-26
10:16:24.393: INFO/MediaPlayer(23736):
Info (1,26) 05-26 10:16:24.393:
ERROR/MediaPlayer(23736): Error
(-10,-10)
HTTP:
VideoView videoView = (VideoView)findViewById(R.id.videoView1);
Uri uri = Uri.parse("http://ikral.garantisistem.com:1935/ikral/smil:kral.smil/playlist.m3u8");
videoView.setVideoURI(uri);
videoView.start();
It gives the message:
"Sorry, this video cannot ve played."
Please add network permission in your AndroidManifest.xml file like this
<uses-permission android:name="android.permission.INTERNET" />