w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Android live stream never starts after MEDIA_INFO_BUFFERING_START with MediaPlayer

http://developer.android.com/guide/topics/media/mediaplayer.html You mast read about "Using wake locks".

To ensure that the CPU continues running while your MediaPlayer is playing, call the setWakeMode() method when initializing your MediaPlayer. Once you do, the MediaPlayer holds the specified lock while playing and releases the lock when paused or stopped:

mMediaPlayer = new MediaPlayer();
// ... other initialization here ...

However, the wake lock acquired in this example guarantees only that the CPU remains awake. If you are streaming media over the network and you are using Wi-Fi, you probably want to hold a WifiLock as well, which you must acquire and release manually. So, when you start preparing the MediaPlayer with the remote URL, you should create and acquire the Wi-Fi lock. For example:

WifiLock wifiLock = ((WifiManager)
    .createWifiLock(WifiManager.WIFI_MODE_FULL, "mylock");


© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.