{"id":1566,"url":"https://github.com/davidlondono/PlayerView","last_synced_at":"2025-08-06T16:32:27.035Z","repository":{"id":62450833,"uuid":"52047462","full_name":"davidlondono/PlayerView","owner":"davidlondono","description":"Player View is a delegated view using AVPlayer of Swift","archived":false,"fork":false,"pushed_at":"2020-06-23T16:52:39.000Z","size":72,"stargazers_count":133,"open_issues_count":6,"forks_count":46,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-08T02:37:40.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidlondono.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-18T23:46:35.000Z","updated_at":"2024-07-18T14:48:14.000Z","dependencies_parsed_at":"2022-11-02T01:01:35.848Z","dependency_job_id":null,"html_url":"https://github.com/davidlondono/PlayerView","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidlondono%2FPlayerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidlondono%2FPlayerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidlondono%2FPlayerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidlondono%2FPlayerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidlondono","download_url":"https://codeload.github.com/davidlondono/PlayerView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228686065,"owners_count":17957032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:50.013Z","updated_at":"2024-12-09T16:31:24.798Z","avatar_url":"https://github.com/davidlondono.png","language":"Swift","funding_links":[],"categories":["Media","Libs","HarmonyOS","Media and Graphics","Video [🔝](#readme)"],"sub_categories":["Video","Other free courses","Windows Manager"],"readme":"# PlayerView\n\n[![CI Status](http://img.shields.io/travis/David Alejandro/PlayerView.svg?style=flat)](https://travis-ci.org/David Alejandro/PlayerView)\n[![Version](https://img.shields.io/cocoapods/v/PlayerView.svg?style=flat)](http://cocoapods.org/pods/PlayerView)\n[![License](https://img.shields.io/cocoapods/l/PlayerView.svg?style=flat)](http://cocoapods.org/pods/PlayerView)\n[![Platform](https://img.shields.io/cocoapods/p/PlayerView.svg?style=flat)](http://cocoapods.org/pods/PlayerView)\n\nAn elegant wraper API for AVPlayer to get events over Delegate so you dount need to use KVO\n\n## Installation\n\nPlayerView is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"PlayerView\"\n```\n\n### CocoaPods\n\n`PlayerView` is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your `Podfile`:\n\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :iOS, '8.0'\nuse_frameworks!\n\npod 'PlayerView'\n```\n\n### Carthage\n\nInstallation is also available using the dependency manager [Carthage](https://github.com/Carthage/Carthage).\n\nTo integrate, add the following line to your `Cartfile`:\n\n```ogdl\ngithub \"davidlondono/PlayerView\" \u003e= 0.2.7\n```\n\n### Swift Package Manager\n\nInstallation can be done with the [Swift Package Manager](https://swift.org/package-manager/), add the following in your `Package.swift` :\n\n```Swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"PlayerView\",\n    dependencies: [\n        .Package(url: \"https://github.com/davidlondono/PlayerView.git\", majorVersion: 0),\n    ]\n)\n```\n\n## Usage\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n\n### Storyboard\nJust add a view and add as a class on **Identity inspector \u003e Custom Class \u003e Class**, make sure to add Module if is imported externaly (Pod, Package manager ....)\n\n```Swift\nimport PlayerView\n```\n\n```Swift\n@IBOutlet var playerVideo: PlayerView!\n```\n\n### Code\n\nJust need to add de view as a normal View:\n\n```Swift\nimport PlayerView\n```\n\n```Swift\n\n\n\nlet playerVideo = PlayerVideo()\n\n//also could add frame:\n// let playerVideo = PlayerVideo(frame: frame)\nview.addSubView(playerVideo)\n\n\n```\n\n## Control\n\n\n```Swift\n//set aspect mode of video\n//default AVLayerVideoGravityResizeAspectFill\nplayerVideo.fillMode = .ResizeAspect\n\n//Set or Get the seconds of the current time of reproduction\n//this will set to reproduce on 3.5 seconds\nplayerVideo.currentTime = 3.5\n\n//define the time interval to get callback delegate of the current time of reproduction, default sends 60 times on 1 second\n//default CMTimeMake(1, 60)\n//this send the time one time per one second\nplayerVideo.interval = CMTimeMake(1, 1)\n\n//set and get the speed of reproduction\n//if speed is set to 0, the video will pause (same as playerVideo.pause())\n//if speed is set to 1,0, the video will pause (same as playerVideo.play())\nplayerVideo.rate = 0.5\n\n//play the video at rate 1.0\nplayerVideo.play()\n\n// pause the video on current time\nplayerVideo.pause()\n\n\n// stop the video on current time\nplayerVideo.stop()\n\n\n// stop the video on current time\nplayerVideo.next()\n\n//to set the url of Video\nif let url = NSURL(string: \"http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4\") {\n\tplayerVideo.url = url\n    //or\n    playerVideo.urls = [url]\n\n    //add videos on queue\n    playerVideo.addVideosOnQueue(urls: [url])\n}\n\n//Take a screenshot on time, and return time to ensure the tolerance of the image\n//on 20.7 seconds\nlet(image1, time1) = playerVideo.screenshotTime(20.7)\n//on actual time\nlet(image2, time2) = playerVideo.screenshotTime()\n\n\n//on actual time\nlet image3 = playerVideo.screenshot()\n\n//reset queue and observers\nplayerVideo.resetPlayer()\n```\n## Delegate\nyou could get event data from the PlayerView, just implement the delegate\nall the functions are optionals\n\n```Swift\nimport PlayerView\nimport AVFoundation\n```\n\n```Swift\n\tplayerVideo.delegate = self\n```\n\n```Swift\n\nextension MyClass:PlayerViewDelegate {\n\n\n\tfunc playerVideo(player: PlayerView, statusPlayer: PlayerViewStatus, error: NSError?) {\n        //got the status of the player\n\t\t//useful to know if is ready to play\n\t\t//if status is unknown then got the error\n    }\n\n\tfunc playerVideo(player: PlayerView, statusItemPlayer: PlayerViewItemStatus, error: NSError?) {\n\t\t//some status got here first, this is the status of AVPlayerItem\n\t\t//useful to know if is ready to play\n\t\t//if status is unknown then got the error\n\t}\n\n\tfunc playerVideo(player: PlayerView, loadedTimeRanges: [PlayerviewTimeRange]) {\n\t\t//got the buffer of the video\n\t\t//to know the progress loaded\n\n\t\t//this will get the seconds of the end of the buffer\n\t\t//loadedTimeRanges.first!.end.seconds\n\n\t}\n\n\tfunc playerVideo(player: PlayerView, duration: Double) {\n\t\t//the player knows the duration of the video to reproduce on seconds\n\t}\n\n\tfunc playerVideo(player: PlayerView, currentTime: Double) {\n\t\t//executed using the playerVideo.interval\n        //only executed when the is reproducing, on pause (rate == 1) this doesn't execute\n\t\t//default executed like 60 frames per seconds, so 60 times on a second\n\t}\n\n\tfunc playerVideo(player: PlayerView, rate: Float) {\n\t\t//if the speed of reproduction changed by pausing, playing or changing speed\n\t}\n\n    func playerVideo(playerFinished player: PlayerView) {\n        //when the video finishes the reproduction to the end\n    }\n}\n```\n\n## Extra Info\n\n- If you like another shorcut, have a better implementation of something or just say thanks,  just send me an email [davidlondono9@gmail.com](mailto:davidlondono9@gmail.com?subject=PlayerView is Awesome)\n\n- Im using a video on http, so I needed to add this on the `info.plist` to accept all on http,\nthis is not safe to use on production, so better to add only trusted domains or use https\n\n```xml\n\u003ckey\u003eNSAppTransportSecurity\u003c/key\u003e\n\u003cdict\u003e\n    \u003c!--Include to allow all connections (DANGER)--\u003e\n    \u003ckey\u003eNSAllowsArbitraryLoads\u003c/key\u003e\n\u003ctrue/\u003e\n\u003c/dict\u003e\n```\n\n## Author\n\nDavid Alejandro, [davidlondono9@gmail.com](mailto:davidlondono9@gmail.com?subject=PlayerView is Awesome)\n\n## License\n\nPlayerView is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidlondono%2FPlayerView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidlondono%2FPlayerView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidlondono%2FPlayerView/lists"}