▶️ video player in Swift, simple way to play and stream media on iOS/tvOS




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

Build Status Pod Version Swift Version GitHub 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


  • 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 the Cocoa dependency manager CocoaPods. Alternatively, you can simply copy the Player.swift file into your Xcode project.

# CocoaPods
pod "Player", "~> 0.13.2"

# Carthage
github "piemonte/Player" ~> 0.13.2


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.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



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()



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




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

  • Issue Playing Local Files

    Issue Playing Local Files

    Hi, Love the Library - Just having a confusing issue - I am also using your NextLevel Camera Library and Player will not display the merged or exported local clips (This also seems to be the case for other local files.) The Implementation is fine, as I have checked that both Player can display remote URL's in the view and that a standard AVPlayer can play the problematic local files. Just curious if this is a known bug or If I am missing something?


    opened by efbsecond 12
  • Problem multiple video

    Problem multiple video

    Hi @piemonte !

    I'm trying to use your lib with a TinderSimpleSwipeCards ( https://github.com/cwRichardKim/TinderSimpleSwipeCards )

    This is the fastest video lib I've found.

    However, when i create 16 card ( 16 Player ), the 17th is not displayed ... , and i dont know why.

    But it works, if i press the home button, then i go back to the application... .

    Any idea ?

    opened by Ze-ro-G 12
  • Most efficient way to play a queue of videos?

    Most efficient way to play a queue of videos?

    Is it possible to play the videos without a gap? Also, how can I minimize memory consumption by reusing the player?

        func playVideo() {
            videoPlayerController.videoPath = self.videoPath;
            // present
            // Start Video
            //videoPlayerController.playbackLoops = true;
        func videoPlayerPlaybackDidEnd(videoPlayer: PBJVideoPlayerController!) {
            // setup next video and call self.playVideo()

    This might be of some interest: https://github.com/katokichisoft/SimpleGaplessPlayer

    opened by switz 12
  • Using player inside a custom TableViewCell

    Using player inside a custom TableViewCell

    Hey Patrick. First things first, thanks for an awesome library, really =)

    Basically, I am trying to implement a Vine-like app which will have a video player inside each cell and other buttons for likes, sharing et cetera. What is your opinion about this and do you think that is this possible with the current design of the library itself?

    opened by ghost 10
  • Improvements: fillMode as Enums

    Improvements: fillMode as Enums

    It is hard to find which fill modes are supported when they are as strings.

    self.player.fillMode = “AVLayerVideoGravityResizeAspect”

    Could you please add the possible fill modes to the documentation or make them available with an enum?

    opened by confile 8
  • deinit not called when using this library?

    deinit not called when using this library?

    I am running into performance issues in my app and I believe they are related to this library, or at least how I am using it.

    I noticed that deinit is never called on the controller that implements Player!

    I have tried a lot of methods for getting it to fire and nothing seems to work:

    dispatch_async(dispatch_get_main_queue()) { if self.player != nil{ self.player!.pause() self.player!.stop() self.player!.view.removeFromSuperview() self.player!.delegate = nil self.player = nil } self.dismissViewControllerAnimated(true, completion: { _ in })

    this helps with memory but does not completely remove the viewController. any ideas?

    opened by uknowmeright 6
  • resuming video doesn't load the video on the exact time

    resuming video doesn't load the video on the exact time


    The Issue I am currently facing is regarding the resuming video from saved time. I am saving the time and when the user launches the same video I am seeking it to that instance of time but the video is not played from the exact time rather its played before some seconds ranging from 1 to 9.

    Here is one scenario, the video saved time is 600 seconds i.e 10 mins and when the video is played, I am playing the video from saved Time interval by seeking to that time using player.seek(to: timeInterval) where timeInterval is of type CMTIME with value as 600 and then I do player.playFromCurrentTime() which will start playing the video from the time stamp I sought to But the video plays from 9:51 ie 591 seconds. Hope I will get an early response.


    opened by majeedyaseen 5
  • Solve issue#166 and 'playbackPausesWhenBackgrounded' doesn't work well.

    Solve issue#166 and 'playbackPausesWhenBackgrounded' doesn't work well.

    Hello! I have been developing an app lately using Player😸


    I found a problem that playbackPausesWhenBackgrounded property doesn't work well. And I found the cause of the problem.

    When pressed the Home button, Player receives UIApplicationWillResignActive notification before receives UIApplicationDidEnterBackground notification. Current handler method for UIApplicationWillResignActive is following. Therefore Player always pauses when background.

    @objc internal func handleApplicationWillResignActive(_ aNotification: Notification) {
        if self.playbackState == .playing {

    Also, I read issue #166. This PR is a solution for these two problem.


    Add playbackPausesWhenResigningActive and playbackResumesWhenBecameActive properties just like playbackPausesWhenBackgrounded and playbackResumesWhenEnteringForeground. And Player controls properly when receive UIApplication notifications.

    Please review🙇

    opened by 131e55 5
  • Snapchat like video preview

    Snapchat like video preview

    @piemonte I would like to be able to instantly show a preview of a video taken by the user - just like Snapchat and more impressive, Instagram stories. Somehow once a user stops capturing a video on both apps, a preview automatically starts playing in an endless loop seemingly within the same view.

    How can I achieve that with Player?

    opened by otymartin 5
  • Fix Carthage Installation

    Fix Carthage Installation

    This does 2 things to fix carthage installations:

    • [x] Share the main Player scheme
    • [x] Duplicate the Player.h umbrella file and rename each to match one of the targets

    Closes #144

    opened by eliotfowler 4
  • Allow setting up Player from local AVAsset

    Allow setting up Player from local AVAsset

    We have an AVAsset from our capture tool. It seems silly to write it to a file just to play it so we made a slight modification to allow setting up the player using the premade Asset.

    Would love to get your feedback!

    opened by eliotfowler 4
  • Player may be crash.

    Player may be crash.

    Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libobjc.A.dylib 0x00000001b290e4ac object_isClass + 16 1 Foundation 0x00000001b2faa5f8 KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 44 2 Foundation 0x00000001b2fa8120 NSKeyValueWillChangeWithPerThreadPendingNotifications + 272 3 AVFoundation 0x00000001bce0aa14 __31-[AVPlayerItem _updateTimebase]block_invoke_2 + 180 4 libdispatch.dylib 0x00000001b28b29a8 dispatch_call_block_and_release + 24 5 libdispatch.dylib 0x00000001b28b3524 dispatch_client_callout + 16 6 libdispatch.dylib 0x00000001b28966fc dispatch_main_queue_callback_4CF$VARIANT$armv81 + 860 7 CoreFoundation 0x00000001b2b6b6bc CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12 8 CoreFoundation 0x00000001b2b66590 __CFRunLoopRun + 1724 9 CoreFoundation 0x00000001b2b65ba8 CFRunLoopRunSpecific + 424 10 GraphicsServices 0x00000001bccd5344 GSEventRunModal + 160 11 UIKitCore 0x00000001b6ca13e4 UIApplicationMain + 1932 12 libswiftUIKit.dylib 0x00000001e97dc2b4 UIApplicationMain+ 45748 (::::) + 168 13 Blessed 0x000000010454dd04 static UIApplicationDelegate.main() + 56580 (:0) 14 Blessed 0x000000010454dc8c static AppDelegate.$main() + 56460 (:0) 15 Blessed 0x000000010454e110 main + 57616 (AppDelegate.swift:0) 16 libdyld.dylib 0x00000001b29ed8f0 start + 4

    opened by ZHDeveloper 0
  • Not working

    Not working

    Hello, I added the following code in the viewDidLoad

        override func viewDidLoad() {
            self.player.playerDelegate = self
            self.player.playbackDelegate = self
            self.player.url = URL(string: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-15.mp3")!

    and added IBaction to play the audio using the below

        @IBAction func playButtonPressed(_ sender: UIButton) {
           // print(self.player.view)

    But unfortunatley , this is not working until I add the code below


    This will load the Player class into memory and it will unlock the isViewLoaded

    How can this be fixed and the audio don't play automatically unless the user click in Play Button

    opened by sam961 0
  • Setting up Player with AVPlayerItem.

    Setting up Player with AVPlayerItem.

    Player stopped working when set up with an AVAsset downloaded from user's iCloud photo library using PHImageManager:

    Error Domain=NSCocoaErrorDomain Code=257 UserInfo={NSURL=file:///var/mobile/Media/PhotoData/Metadata/DCIM/101APPLE/IMG_1858.small.MP4, NSUnderlyingError=0x2833487b0 {Error Domain=NSOSStatusErrorDomain Code=-12203 "(null)"}}

    Related posts:

    Swift AVAsset downloading from iCloud has no permission on iOS 14: error Code=257

    Request AVAsset using iCloud PHAsset returns an AVAsset with no VideoTracks


    Set up Player with an AVPlayerItem.

    PHImageManager provides either an AVAsset or an AVPlayItem for a video request from user's photo library. This issue does not occur when working with an AVPlayerItem.

    opened by lurui1029 0
patrick piemonte
patrick piemonte
VLC for iOS and tvOS official mirror

This is the official mirror repository of VLC for iOS and tvOS application. You can find the official repository here. It's currently written in Objec

VideoLAN 798 Dec 28, 2022
An app focused on show in a visual way how sorting algorithms actually works.

Sorting Algorithms App An open source app focused on show in a visual way how sorting algorithms actually works. Available on the app store Do you wan

Victor Panitz Magalhães 45 Nov 25, 2022
Simple sample of using the VIP (Clean Swift) architecture for iOS

MyAnimeList Simple sample of using the VIP (Clean Swift) architecture for iOS. ViewController: controls the event handling, view life cycle and displa

null 24 Oct 12, 2022
A simple and beautiful barcode scanner.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

HyperRedink 1.6k Dec 28, 2022
Firefox for iOS, branch works with Xcode 12.5.1, Swift 5.4.2 and supports iOS 11.4 and above.

Firefox for iOS Download on the App Store. This branch (main) This branch works with Xcode 12.5.1, Swift 5.4.2 and supports iOS 11.4 and above. Please

Mozilla Mobile 11.2k Jan 7, 2023
Development of the TUM Campus App for iOS devices - for and from students at Technical University of Munich.

Tum Campus App - An Unofficial Guide Through University Life The TUM Campus App (TCA) is an open source project, developed by volunteers and available

TUM Developers 93 Dec 16, 2022
Alfresco iOS App - Alfresco is the open platform for business-critical content management and collaboration.

Welcome to the Alfresco iOS App Alfresco is the open platform for business-critical content management and collaboration. Alfresco Mobile was designed

Alfresco Software 42 Sep 26, 2022
📱 Wire for iOS (iPhone and iPad)

Wire™ This repository is part of the source code of Wire. You can find more information at wire.com or by contacting [email protected]. You can find

Wire Swiss GmbH 3.2k Jan 8, 2023
PHPHub for iOS is the universal iPhone and iPad application for PHPHub

PHPHub is a Forum project written in Laravel 4.2, and it is also the project build up PHP & Laravel China community. PHPHub for iOS is the universal i

Aufree 1.2k Nov 18, 2022
Basic app to show how to login with Facebook, Google, Twitter. Created for learning purpose :) using Xcode 9 and Swift 4.0

Social Logins iOS Basic app to show how to login with Facebook, Google, Twitter. Created for learning purpose :) using Xcode 9 and Swift 4.0 Note: Bef

Jogendra 12 Nov 4, 2022
A Swift mailing list client for iPhone and iPad

Due to costs and lack of interest, I’ve had to take down the Charter service. If you’re interested in running your own copy, get in touch and I can se

Matthew Palmer 526 Dec 24, 2022
Fully open source text editor for iOS written in Swift.

Edhita Fully open source text editor for iOS written in Swift. http://edhita.bornneet.com/ What Edhita means? Edhita (Romaji) == エディタ (Katakana) == Ed

Tatsuya Tobioka 1.2k Jan 7, 2023
This app shows the current percentage of the vaccination campaign in Brazil and its states

This app shows the current percentage of the vaccination campaign in Brazil and its states. The data is obtained thanks to covid19br.

Anderson Kloss Maia 8 Jul 22, 2022
Sample app to demonstrate data sharing between a WatchKit app and its main app using Realm

#Done! A sample app demonstrating how to share data between an app an its Watch extension using Realm. You can read more about it here. ##Screenshot #

Fancy Pixel 147 Dec 8, 2022
TriangleDraw is a pixel editor for iPad and iPhone.

TriangleDraw TriangleDraw is brilliant for sketching logos. You can quickly create designs that can be used for branding on letterheads or on your web

TriangleDraw 46 Sep 26, 2022
An iOS widget-based HN reader

Benuse, an iOS widget-based HN reader Why did you build this app? There already exist some great native Hacker News clients for iOS. I would recommend

Jordan Mann 8 Jul 21, 2022
iOS app to record how much things cost using various data persistence implementations.

how-much iOS app to record how much things cost using various data persistence implementations. The basic data unit is an item, a simple dictionary: {

null 22 Aug 15, 2022
The (second) best iOS app for GitHub.

GitHawk is the second-highest rated iOS app for GitHub. Features 0️⃣ Inbox Zero your notifications ?? Comment even faster than on GitHub desktop ?? Th

GitHawk 2.8k Dec 23, 2022
WordPress for iOS - Official repository

WordPress for iOS Build Instructions Please refer to the sections below for more detailed information. The instructions assume the work is performed f

WordPress Mobile 3.4k Jan 9, 2023