MPMoviePlayer 跳到电影中的时间
我正在使用 MPMoviePlayer 来播放电影。我希望能够播放电影并允许用户通过按按钮跳到电影中的某个时间。
我正在设置播放器的 currentPlaybackTime 属性,但它似乎不起作用。相反,它只是从一开始就对电影进行统计,无论我使用什么值。
另外,我通过单击按钮记录 currentPlaybackTime 属性,它总是返回一个大数字,但有时返回一个负值?!这是预期的吗? (例如-227361412)
示例代码如下:
- (IBAction) playShake
{
NSLog(@"playback time = %d",playerIdle.currentPlaybackTime);
[self.playerIdle setCurrentPlaybackTime:2.0];
return;
}
I'm using the MPMoviePlayer to play a movie. I want to be able to play the movie and allow the user to skip to a certain time in the film at the press of a button.
I'm setting the currentPlaybackTime property of the player but it doesn't seem to work. Instead it simply stats the movie from the beginning no matter what value I use.
Also I log the currentPlaybackTime property through a button click, it always returns a large number but it sometimes returns a minus value?! is this expected? (e.g. -227361412)
Sample code below:
- (IBAction) playShake
{
NSLog(@"playback time = %d",playerIdle.currentPlaybackTime);
[self.playerIdle setCurrentPlaybackTime:2.0];
return;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我过去曾成功地使用过这种跳到电影中某个点的方法。我怀疑你的问题实际上是视频本身。当您设置 currentPlaybackTime 时,MPMoviePlayer 将跳到视频中最近的关键帧。如果视频的关键帧很少,或者您只向前跳几秒钟,则当您更改 currentPlaybackTime 时,可能会导致视频从头开始。
I have successfully used this method of skipping to a point in a movie in the past. I suspect that your issue is actually with the video itself. When you set the currentPlaybackTime MPMoviePlayer will skip to the nearest keyframe in the video. If the video has few keyframes or you're only skipping forward a few seconds this could cause the video to start over from the beginning when you change the currentPlaybackTime.
-currentPlaybackTime
返回一个NSTimeInterval (double)
,您将其打印为有符号整数。这将导致意外的值。尝试转换为 int(int)playerIdle.currentPlaybackTime
或打印双精度%1.3f
。-currentPlaybackTime
returns aNSTimeInterval (double)
which you are printing as a signed int. This will result in unexpected values. Try either casting to int(int)playerIdle.currentPlaybackTime
or printing the double%1.3f
.