views:

656

answers:

2

Hi all,

I have this situation: Play (streamed) video, 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?

tnx

A: 

can you be little more clear with your question. are you asking as that your video is not stopping from where you stopped or do you need to resume from the beginning??

glenda
i need to stop from x second, and replay from x second.this is on streamed video, not local.
donodare
A: 

Hi,

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 :)

deanWombourne
Stop should just pause the video so this should not be necessary. Maybe he starts it with the URL again or something.
willcodejavaforfood
Ah, a quick re-read of the docs and you're absolutely right, if it's play on the same movie player instance it should be fine.
deanWombourne
All of you use the word should a lot.Have you tried it ?
donodare