0

I have a situation with the android MediaPlayer object. I'm playing a m3u8 file from a server and I was wondering if there's a way for the player to load the streaming only once?
What's going on is that I enter the activity, and when this is loading, I go and play the stream, but when I go landscape, the player reloads, causing the app to slow down a bit.
Here's my code, that handles the load thing:

MediaController mc = new MediaController(this);

mVideoView.setMediaController(mc);         
final String urlStream = Constantes.URL_VIDEO;
runOnUiThread(new Runnable() {
    @Override
    public void run() {
        startLoader();
        mVideoView.setVideoURI(Uri.parse(urlStream));  
        mVideoView.start();
    }
});     

Any help is always appreciated!

pamobo0609
  • 812
  • 10
  • 21

1 Answers1

1

When you rotate the device, the activity is destroyed and created again with the new configuration. If you don't use different layouts for the landscape/portrait modes, then you can use android:configChanges="orientation|screenSize" in the manifest in that activity's tag. In case of using different layouts, read this: https://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange and this: layout-land xml files does not work with onConfigurationChanged call back

Community
  • 1
  • 1
smb
  • 834
  • 1
  • 8
  • 17
  • I've tried with the links, with no success... I don't know if there's like an option kinda like youtube or any player, where the object itself goes fullscreen... – pamobo0609 Apr 20 '15 at 19:48