I'm trying to display the video stream from my wifi camera (SJ6 Legend) to an Android device.
When turning on the wifi from the camera and connecting to its network from my mac I can see the video stream from vlc simply by going to File -> Open Network and connecting to rtsp://MY_CAM_IP.
I then connect to the wifi from my android device and I tried using MediaPlayer
or VideoView
and it doesn't work.
vlc for android also doesn't display the video.
Just to make sure there is no problem playing RTSP I tried this file: rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov
and it works fine on vlc for android and using MediaPlayer
.
I also tried a vlc for android lib, that didn't work as well...
Relevant code:
In onCreate:
SurfaceView surfaceView = (SurfaceView)
findViewById(R.id.am_surface_view);
mSurfaceHolder = surfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setFixedSize(320, 240);
and:
/**
* {@link MediaPlayer.OnPreparedListener} interface methods
*/
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mMediaPlayer.start();
}
/**
* {@link SurfaceHolder.Callback} interface methods
*/
@Override
public void surfaceChanged(final SurfaceHolder holder, final int format, final int width, final int height) {}
@Override
public void surfaceCreated(SurfaceHolder sh) {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDisplay(sh);
// Context context = getApplicationContext();
// Map<String, String> headers = getRtspHeaders();
// Uri source = Uri.parse(RTSP_URL);
try {
// Specify the IP camera's URL and auth headers.
// mMediaPlayer.setDataSource(context, source, headers);
// mMediaPlayer.setDataSource(context, source);
mMediaPlayer.setDataSource(RTSP_URL); // RTSP_URL = "rtsp://MY_CAM_IP"
// Begin the process of setting up a video stream.
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (Exception e) {}
}
@Override
public void surfaceDestroyed(SurfaceHolder sh) {
mMediaPlayer.release();
}
Anyone can point me to some solution???
Thanks