开发者

mpmovieplayercontroller stop function, and then play with current time (iPhone)

开发者 https://www.devze.com 2022-12-17 19:59 出处:网络
I have this situation: Play (streamed) vid开发者_如何学JAVAeo, stop by code the video, and then play again.

I have this situation: Play (streamed) vid开发者_如何学JAVAeo, stop by code the video, and then play again. The problem is that the video is begin from the start and not when i stopped it.

What solution do you now of?


EDIT: As @willcodejavaforfood has pointed out, stop only pauses the movie - calling play should restart where you left off so you shouldn't ever need my answer! Can you post the code you are using so we can see what's going on? Thanks.


If you want it to restart where you left off, you will need to remember how far through the movie you were and set the initialPlaybackTime property before you call play again.

i.e. Store the time when you start the movie

...
[myMoviePlayer start];
startDate = [[NSDate date] retain];
...

Store the time you stop the movie

...
[myMoviePlayer stop];
endDate= [[NSDate date] retain];
...

And when you start playback again, use the difference between these times

...
[myMoviePlayer setInitialPlaybackTime:[endDate timeIntervalSinceDate:startDate]];
[myMoviePlayer play];
...

Sam

PS To force it to start at the start, just set the initial playback time to 0.0

PPS I don't know how accurate NSDate is in milliseconds so you might have to use a better way of working out the current position in the movie :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号