Skip to content
프로젝트

소개

▶️ Swift로 미디어 재생 및 스트리밍

디자인 및 미디어

이 수치를 측정하는 방법

What you can do

  • plays local media or streams remote media over HTTP
  • customizable UI and user interaction
  • no size restrictions
  • orientation change support

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
+11

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Player

Player

Player is a simple iOS/tvOS video player library written in Swift.

Platform Swift Version SPM Compatible Pod Version License

Need a different version of Swift?

  • 5.0 - Target your Podfile to the latest release or master
  • 4.2 - Target your Podfile to the swift4.2 branch
  • 4.0 - Target your Podfile to the swift4.0 branch

Features

  • plays local media or streams remote media over HTTP
  • customizable UI and user interaction
  • no size restrictions
  • orientation change support
  • simple API
  • video frame snapshot support

Quick Start

Player is available for installation using Swift Package Manager, CocoaPods, or by manually copying the Player.swift file into your Xcode project.

Swift Package Manager

Add Player to your Package.swift dependencies:

dependencies: [
    .package(url: "https://github.com/piemonte/Player.git", from: "0.15.0")
]

Or add it directly in Xcode via File > Add Package Dependencies and enter the repository URL.

CocoaPods

pod "Player", "~> 0.15.0"

Manual Installation

Simply copy the Player.swift file from the Sources directory into your Xcode project.

Usage

The sample project provides an example of how to integrate Player, otherwise you can follow these steps.

Allocate and add the Player controller to your view hierarchy.

 self.player = Player()
 self.player.playerDelegate = self
 self.player.playbackDelegate = self
 self.player.view.frame = self.view.bounds

 self.addChild(self.player)
 self.view.addSubview(self.player.view)
 self.player.didMove(toParent: self)

Provide the file path to the resource you would like to play locally or stream. Ensure you're including the file extension.

let videoUrl: URL = // file or http url
self.player.url = videoUrl

For HTTP streams with custom headers, use AVAsset:

let videoUrl: URL = // http url
let headers = ["Authorization": "Bearer token123"]
let asset = AVURLAsset(url: videoUrl, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])
self.player.asset = asset

For iCloud Photos or PHAsset videos, use AVPlayerItem:

let playerItem: AVPlayerItem = // your player item
self.player.playerItem = playerItem

play/pause

 self.player.playFromBeginning()

Adjust the fill mode for the video, if needed.

 self.player.fillMode = .resizeAspectFit

Display video playback progress, if needed.

extension ViewController: PlayerPlaybackDelegate {

    public func playerPlaybackWillStartFromBeginning(_ player: Player) {
    }

    public func playerPlaybackDidEnd(_ player: Player) {
    }

    public func playerCurrentTimeDidChange(_ player: Player) {
        let fraction = Double(player.currentTime) / Double(player.maximumDuration)
        self._playbackViewController?.setProgress(progress: CGFloat(fraction), animated: true)
    }

    public func playerPlaybackWillLoop(_ player: Player) {
        self. _playbackViewController?.reset()
    }

}

Documentation

You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.

Community

Resources

License

Player is available under the MIT license, see the LICENSE file for more information.

관련 프로젝트 살펴보기

불러오는 중…