Skip to content

Repository files navigation

XRPlayer

基于AVPlayer封装的视频播放器,支持横竖屏切换,支持快进快退,支持Http协议视频流。 The video player based on avplayer package supports horizontal and vertical screen switching, fast forward and backward, and HTTP protocol video stream.

Requirements

  • iOS 9.0+
  • Xcode 10+
  • Swift 4.2+

Component

Usage

playerView = XRPlayer(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width / 16.0 * 10.0), url: url)
self.view.addSubview(playerView)
playerView.isAutoToPlay = false
playerView.title = "测试标题"

playerView.coverImageURL = ""

playerView.delegate = self

playerView.playerOrientationDidChangedClosure = { [weak self](isFullScreenPlay) in
    if let weakSelf = self {
        weakSelf.isHiddenStatusBar = isFullScreenPlay
        weakSelf.setNeedsStatusBarAppearanceUpdate()
    }
}

playerView.playerBackButtonActionClosure = { [weak self] in
    if let weakSelf = self {
        if weakSelf.playerView.isFullScreenPlay {
            weakSelf.playerView.exitFullScreenPlayWithOrientationPortraint()
        }
        else {
            weakSelf.navigationController?.popViewController(animated: true)
        }
    }
}

Reveal

image-w100 image-w100

About

基于`AVPlayer`的音视频播放器,支持mp4,avi,mov,mp3媒体播放。The audio and video player based on 'avplayer' supports MP4, avi, MOV and MP3 media playback.

Topics

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages