ios - 慢动作播放 MPMoviePlayerController
<p><p>我正在编写一个应用程序,它需要能够播放用户的所有视频,包括慢动作视频。我的代码适用于普通视频,但 Slo-Mo 视频正在以正常速度(不是慢动作)播放。我已经用谷歌搜索并搜索了 SO,但无法找到任何代码示例来使其正常工作。 </p>
<p>我通过执行以下操作获取 Assetsurl:</p>
<pre><code>PHVideoRequestOptions *options = ;
options.deliveryMode =PHVideoRequestOptionsDeliveryModeHighQualityFormat;
options.version = PHVideoRequestOptionsVersionOriginal;
[ requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
if (])
completion(((AVURLAsset *)asset).URL);
}];
</code></pre>
<p>然后我将 URL 传递给 MPMoviePlayerController:</p>
<pre><code>_moviePlayer.view.frame = self.view.frame;
_moviePlayer.allowsAirPlay = true;
_moviePlayer.shouldAutoplay = true;
_moviePlayer.movieSourceType = MPMovieSourceType.File;
_moviePlayer.scalingMode = MPMovieScalingMode.AspectFit;
_moviePlayer.controlStyle = MPMovieControlStyle.Default;
_moviePlayer.view.autoresizingMask = ;
_moviePlayer.contentURL = url!;
_moviePlayer.prepareToPlay();
_moviePlayer.play();
</code></pre>
<p>任何帮助将不胜感激。</p>
<p>谢谢</p>
<p>雅各布</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>尝试更改 <a href="https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMediaPlayback_protocol/index.html#//apple_ref/occ/intfp/MPMediaPlayback/currentPlaybackRate" rel="noreferrer noopener nofollow">MPMediaPlayback Protocol</a> 中声明的 <code>currentPlaybackRate</code> 属性.这是因为如果您使用 <code>PHVideoRequestOptionsVersionOriginal</code>,Slo-Mo 视频将以高 FPS 完全播放而不是减慢速度。</p>
<p>还请注意,MPMoviePlayerController 在 iOS 9 中已被弃用。相反,您应该使用 <a href="https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayerViewController_Class/index.html#//apple_ref/occ/cl/AVPlayerViewController" rel="noreferrer noopener nofollow">AVPlayerViewController</a> .</p>
<p>AVPlayerViewController 有一个 <a href="https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayer_Class/index.html" rel="noreferrer noopener nofollow">AVPlayer</a>作为它的播放器。您可以更改 AVPlayer 的 <code>rate</code> 属性以慢动作播放视频。如果您想编辑 Assets 本身,请查看以下问题:<a href="https://stackoverflow.com/questions/17296999/how-to-do-slow-motion-video-in-ios" rel="noreferrer noopener nofollow">How to do Slow Motion video in IOS</a> </p></p>
<p style="font-size: 20px;">关于ios - 慢动作播放 MPMoviePlayerController,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34869390/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34869390/
</a>
</p>
页:
[1]