播放视频的特定部分

时间:2017-03-27 11:31:25

标签: ios swift avplayer

我想使用AVPlayerController播放视频的特定部分。但不知道怎么玩。这是我的代码

func playVideoMethod(path:URL) {       

    avpController = AVPlayerViewController()
    avpController.player = AVPlayer.init(url: path)
    avpController.view.frame = self.playerView.bounds
    avpController.showsPlaybackControls = false
    let translate = CGAffineTransform(rotationAngle: CGFloat(Int(M_PI/18.0)))
    avpController.view.transform = translate
    self.playerView.addSubview(avpController.view)
    self.playerView.autoresizesSubviews = true
    avpController.player?.play()
}

2 个答案:

答案 0 :(得分:1)

您可以对代码进行修改:

let item = AVPlayerItem(url: path)
let player = AVPlayer(playerItem: item)
player.seek(to: CMTime(... // add time what you want to start from
item.forwardPlaybackEndTime = CMTime(... // add preferred end time
avpController.player = player

答案 1 :(得分:0)

SaveAsUI