In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to use the seekto () method of mediaplayer in Android". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn "how to use the seekto () method of mediaplayer in Android".
When android uses mediaPlayer to play video videos, when a user exits the current playback and resumes playback from the background, he / she needs to jump to the previous exit point to continue playback. The methods used are basically the point in time before SeekTo, but often encounter the problem of incorrect position when resuming playback, and even start playing all over again. This is because the SeekTo is caused by going back to the Keyframe near the previous point in time.
Seekto () method usage of mediaplayer in Android
1. The parameter of the seekto method is millisecond, not seconds, so you should pay attention to the parameter passing.
2. The seekto method is asynchronous, so if you want to write:
MediaPlayer.seekTo (10000)
MediaPlayer.start ()
It has no effect.
3. My personal test seekto has to be written after prepare to be effective, but I'm not sure I have to do it.
The correct method of seekto ()
If you want the video to start playing in xxxx milliseconds, the correct thing to do is:
First configure the properties for mediaPlayer
MediaPlayer.setDisplay (videoSurface.getHolder ())
MediaPlayer.setAudioStreamType (AudioManager.STREAM_MUSIC)
Try {
MediaPlayer.setDataSource (filePath)
MediaPlayer.prepare ()
MediaPlayer.seekTo (millis)
} catch (IOExceptione) {
}
Then add a listening OnSeekCompleteListener () for mediaPlayer
MediaPlayer.setOnSeekCompleteListener (newOnSeekCompleteListener () {
PublicvoidonSeekComplete (MediaPlayerm) {
M.start ()
IsPlaying=true
}
})
The above is all the content of the article "how to use the seekto () method of mediaplayer in Android". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.