Reputation: 812
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!
Upvotes: 0
Views: 564
Reputation: 834
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
Upvotes: 1