Hi Cliffus, I have exactly the same issue here. A service handing the MediaPlayer, and I would like to disconnect/reconnect the video when activities are launched/stopped. I tried several strategies : - creatig a "false" Surface Holder that would hide the surface destroyed and delegating to the real SurfaceHolder when set. - Using setDisplay(null), not setting it to null when surface is destroyed...
None of these strategies seems to work, at least on the two devices I am testing. IMHO, when using setDisplay(null) or when the Surface becomes invalid, the MediaPlayer is not working for Video anymore... I see two possibilities to solve this : - use two separate streams, one for video, the other for audio, and enable only video when creating the activities - when creating an activity if setDisplay() has already been called once, create a new MediaPlayer, prepare it and when it is ready, replace the old MediaPlayer... but unfortunatly, it will create an Audio artifact :( Do you have other ideas ? Cheers Pierre Souchay On 27 fév, 17:01, Cliffus <cliff.ophalv...@gmail.com> wrote: > Hi > > we're creating an application for a radio station. The concept of the > application is a little bit different than a normal radio application. > When the user hits the play button, a video starts playing (webcam) > and with the audio in the background. To accomplish this, a have a > background service with a Mediaplayer object. From activity A, I start > the service and connect a surfaceview to it with the 'setDisplay' > method. > > When navigating from Activity A to Activity B, in 'onPause', I > disconnect the surfaceview from the mediaplayer. When Activity B is > created, you can stil hear the audio from the video stream playing in > the background (that's a good thing!). > > When the user hits the back button, Activity B is finishing and > Activity A resumes. In 'onResume', I reconnect the surfaceview with > the mediaplayer (which is playing in the background surface). But now > the surfaceview stays black, the audio is stil playing though. > > I don't have this issue on my Galaxy nexus (Android 4), but I wonder > if anyone has a solution for this 'bug'? > > Thanks in advance! > Cliff -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en