I have one main MediaPlayer which plays nicely an RTSP stream and I have used an AsyncTask to buffer the content of another stream. It achieves this. When I try to switch to the second stream, I can hear that the stream switched and it doesn't lag, but I only get sound. The SurfaceHolder holds a VideoView, it has been prepared, I registered it as Display for both mediaplayers. When I switch streams, I stop the old MediaPlayer but the surface doesn't get destroyed, which is good, but it doesn't display my second video. Any ideas?
Asked
Active
Viewed 1,185 times
1 Answers
0
Could you supply your VideoView instantiation code and the code you use to switch out the MediaPlayers?
In any case, I doubt this will work well because the VideoView instantiates its own MediaPlayer and uses it to play media. (see VideoView.java)
You would probably need to switch out the VideoView itself, or build a replacement for the VideoView using your own subclass of SurfaceView.

Matthew
- 44,826
- 10
- 98
- 87
-
VideoView instantiation is the standard one in the Android documentation, I attach it to a SurfaceHolder and then call setDisplay(mHolder) on my MediaPlayer. I understand what you say about the VideoView and its own mediaplayer, but how can I take advantage of the mediaplayer that is already prepared() and ready to start()? Should I instantiate 2 VideoViews and make the old VideoView invisible and my the new one associated to the second MediaPlayer visible? Thanks for your answer! – dulys Feb 25 '11 at 18:30
-
Can you show me the link to the VideoView instantiation you're talking about? If you're using VideoView, then your code shouldn't mention MediaPlayer (except in some VideoView callbacks that supply a MediaPlayer to you). A good starting point for how to develop your own custom SurfaceView would be VideoView.java, changing it (or subclassing it) to switch out two different MediaPlayers in one view. – Matthew Feb 25 '11 at 19:18
-
Please also see: http://stackoverflow.com/questions/4096273/what-are-the-difference-between-mediaplayer-and-videoview-for-android – Matthew Feb 25 '11 at 19:19
-
Thanks a bunch for the answer. I realize now that for what I need, I should make a custom implementation of VideoView. The other answer pointed to that as well. – dulys Feb 25 '11 at 20:06