So far i am making progress with a video app i am working on using the media player and a looping function. After a few tests, I am concerned the app will be a battery hog if i cannot stop the video loop when the phone reaches the sleep state. Can anyone give me a quick me a way 开发者_如何学编程to fix this?
I never implemented media player on android but i suggest that you keep the screen on with the xml attribute keepscreenon, as users watching videos are usually don't touch the screen and are likly expecting the screen not shutting down. But if you insist than i think you need to save the current time of the video in onpuase and resume the video from the saved time in onresume.
Actually I added a stop function to the media player that stops the video when the app is no longer visible on the screen. Still testing but so far its saving battery power and is functioning flawlessly.
精彩评论