从整个视频播放3秒部分

时间:2012-09-11 12:38:46

标签: iphone objective-c video ios4 cocos2d-iphone

我有一个10秒长的视频片段,我想播放它从3秒到6秒。这对CCPlayer有可能吗?甚至是MPMoviewPlayer?

这是我的代码:

MPMoviePlayerController *_theMovie;  
[_theMovie setCurrentPlaybackTime:1.0];  
[_theMovie setEndPlaybackTime:2.0];  
[_theMovie play];  

但视频播放时间为0到2秒:(

由于

2 个答案:

答案 0 :(得分:1)

以下是docs中的两个setter。

// The start time of movie playback. Defaults to NaN, indicating the natural start time of the movie.
@property(nonatomic) NSTimeInterval initialPlaybackTime;

// The end time of movie playback. Defaults to NaN, which indicates natural end time of the movie.
@property(nonatomic) NSTimeInterval endPlaybackTime;


MPMoviePlayerController *_theMovie;
[theMovie setInitialPlaybackTime:3.0]; //instead of [_theMovie setCurrentPlaybackTime:1.0];
[theMovie setEndPlaybackTime:6.0];
[_theMovie prepareToPlay];
[_theMovie play];

:)

答案 1 :(得分:0)

更改MPMoviewPlayer中的currentPlaybackRate时间,

moviplayer.currentPlaybackRate =moviePlayer.duration/3 or  6;