MPMoviePlayer 跳到电影中的时间

发布于 2024-10-18 08:04:13 字数 447 浏览 2 评论 0原文

我正在使用 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 技术交流群。

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

发布评论

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

评论(2

温柔女人霸气范 2024-10-25 08:04:13

我过去曾成功地使用过这种跳到电影中某个点的方法。我怀疑你的问题实际上是视频本身。当您设置 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.

倾其所爱 2024-10-25 08:04:13

-currentPlaybackTime 返回一个 NSTimeInterval (double),您将其打印为有符号整数。这将导致意外的值。尝试转换为 int (int)playerIdle.currentPlaybackTime 或打印双精度 %1.3f

-currentPlaybackTime returns a NSTimeInterval (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.

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