mpmovieplayercontroller 停止功能,然后以当前时间播放(iPhone)

发布于 2024-08-18 04:46:14 字数 88 浏览 12 评论 0原文

我有这样的情况: 播放(流式传输)视频,通过编码停止视频,然后再次播放。 问题是视频是从头开始的,而不是我停止时开始的。

您现在采取什么解决方案?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕花眠 2024-08-25 04:46:14

编辑:正如@willcodejavaforfood所指出的, stop 仅暂停电影 - 调用 play 应该从您停止的地方重新开始,因此您不需要我的答案!您可以发布您正在使用的代码,以便我们看看发生了什么吗?谢谢。


如果您希望它从上次中断的地方重新开始,您需要记住您看完电影的进度并设置 initialPlaybackTime 属性,然后再次调用播放。

ie 存储开始电影的时间

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

存储停止电影的时间 当你

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

再次开始播放时,使用这些时间之间的差值

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

Sam

PS 要强制它从头开始,只需将初始播放时间设置为 0.0

PPS I不知道 NSDate 以毫秒为单位有多准确,因此您可能必须使用更好的方法来计算电影中的当前位置:)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文