Skip to content

CharonYH/YHPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YHPlayer

An easy-to-use video player based on swift language

CI Status Version License Platform

Features

  • Plays local media or streams remote media over HTTP
  • Custom UI control layer screen
  • Support screen rotation
  • Simple API
  • Clear delegate method
  • Audio Default is muted
  • AutoPlay Default is False

Requirements

iOS 11.0 or later
xcode 11.0 or later

Installation

YHPlayer is available through CocoaPods. To install it, simply add the following line to your Podfile:

target 'YourProductName' do
    pod 'YHPlayer', :git => 'https://github.com/CharonYH/YHPlayer.git' #Prevent slow remote pod updates
    
    or pod 'YHPlayer' #Directly
    ...

Install pods

$ pod install

And then import import YHPlayer where you use.

How to use

1.create YHPlayer
        let playView = YHPlayer(frame: .zero)
        playView.delegate = self
2.create YHPlayerItemConfig
        let itemConfig = YHPlayerItemConfig(videoURL: videoURL1,
                                            isMuted: false,
                                            isAutoPlay: false,
                                            thumbImg: .init(named: "thumbimg"))
3.set itemConfig to player
        playView.config(with: itemConfig)
4.custome your controlPanel
        playView.addCustomeControl(controlView)

YHPlayerDelegate

public protocol YHPlayerDelegate: NSObjectProtocol {
    /// 更新播放进度
    func yhPlayer(_ player: YHPlayer, notifyCurrentProgress progress: TimeInterval)
    
    /// 更新缓冲进度
    func yhPlayer(_ player: YHPlayer, notifyBufferProgress progress: TimeInterval)
    
    /// 准备播放
    func yhPlayerReadyToPlay(_ player: YHPlayer)
    
    /// 失败播放
    func yhPlayerFailedToPlay(_ player: YHPlayer, error: YHPlayer.Error)
    
    /// 播放完毕
    func yhPlayerDidEndPlaying(_ player: YHPlayer)
    
    /// 播放中断(来电话等优先级高的)
    func yhPlayerInterruptioned(_ player: YHPlayer, interruptionType type: YHPlayer.InterruptionType)
    
    /// 状态发生改变
    func yhPlayerStatusChanged(_ player: YHPlayer, status: YHPlayer.PlayStatus)
}

Run result

Author

YEHAN, 2436567084@qq.com

License

YHPlayer is available under the MIT license. See the LICENSE file for more info.

About

An easy-to-use video player based on swift language

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published