### Cocoapods Installation Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Instructions for adding the api.video Swift Player to your iOS project using Cocoapods, including the Podfile configuration and the installation command. ```swift pod 'ApiVideoPlayer', 'USE_THE_LATEST_RELEASE' ``` -------------------------------- ### api.video Documentation Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Links to the main api.video documentation for broader context and information. ```APIDOC api.video Documentation: URL: https://docs.api.video ``` -------------------------------- ### Swift Package Manager Installation Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Instructions for adding the api.video Swift Player to your iOS project using Swift Package Manager, including the repository URL and Package.swift dependency configuration. ```swift dependencies: [ .package(url: "https://github.com/apivideo/api.video-swift-player.git", from: "USE_THE_LASTEST_RELEASE"), ], ``` -------------------------------- ### API Documentation Reference Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Provides a link to the detailed API documentation for the api.video Swift Player. ```APIDOC API Documentation: URL: https://apivideo.github.io/api.video-swift-player/documentation/apivideoplayer/ ``` -------------------------------- ### ApiVideoPlayerAnalytics Dependency Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Details the ApiVideoPlayerAnalytics plugin used as a dependency, with a link to its README. ```APIDOC Dependency: ApiVideoPlayerAnalytics README: https://github.com/apivideo/api.video-swift-player-analytics#readme ``` -------------------------------- ### Cocoapods Installation Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Instructions for adding the api.video Swift player to your project using Cocoapods. This involves adding the pod to your Podfile and running the install command. ```objective-c pod 'ApiVideoPlayer', '1.3.0' ``` -------------------------------- ### Documentation Style Guide Source: https://github.com/apivideo/api.video-swift-player/blob/main/CONTRIBUTING.md Specifies that documentation should be written using Markdown, a lightweight markup language with plain text formatting syntax. ```markdown # Use [Markdown](https://daringfireball.net/projects/markdown). ``` -------------------------------- ### Importing the ApiVideoPlayer Library Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Demonstrates how to import the api.video Swift Player library into your Swift code. ```swift import ApiVideoPlayer ``` -------------------------------- ### Instantiating the Player View Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Shows how to create an instance of the ApiVideoPlayerView, configuring it with a video ID and type. Supports both VOD and private videos with an optional token. ```swift let playerView: ApiVideoPlayerView = ApiVideoPlayerView(frame: .zero, videoOptions: VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod)) // for private video VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod, token: "YOUR_PRIVATE_VIDEO_TOKEN") ``` -------------------------------- ### Adding Player View as Subview Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Example of how to add the instantiated player view as a subview within your view controller's view hierarchy. ```swift override func viewDidLoad() { ... self.addSubview(playerView) } ``` -------------------------------- ### Player Delegate Protocol Implementation Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Provides a comprehensive implementation of the PlayerDelegate protocol, outlining various player events such as didPrepare, didPlay, didPause, didError, and more. ```swift extension YourViewController: PlayerDelegate { public func didPrepare() { // Do what you want when didPrepare is called } public func didReady() { // Do what you want when didReady is called } public func didPause() { // Do what you want when didPause is called } public func didPlay() { // Do what you want when didPlay is called } public func didReplay() { // Do what you want when didReplay is called } public func didMute() { // Do what you want when didMute is called } public func didUnMute() { // Do what you want when didUnMute is called } public func didLoop() { // Do what you want when didLoop is called } public func didSetVolume(_: Float) { // Do what you want when didSetVolume is called } public func didSeek(_: CMTime, _: CMTime) { // Do what you want when didSeek is called } public func didEnd() { // Do what you want when didEnd is called } public func didError(_: Error) { // Do what you want when didError is called } public func didVideoSizeChanged(_: CGSize) { // Do what you want when didVideoSizeChanged is called } } ``` -------------------------------- ### Registering the Player Delegate Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Demonstrates how to register your view controller as a delegate for the player events to receive callbacks. ```swift override func viewDidLoad() { ... self.playerView.addDelegate(self) } ``` -------------------------------- ### Enabling Fullscreen Mode Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Getting Started.md Explains how to enable fullscreen playback by assigning the view controller to the player view's viewController property. ```swift override func viewDidAppear(_ animated: Bool) { ... playerView.viewController = self } ``` -------------------------------- ### Swift Package Manager Installation Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Instructions for adding the api.video Swift player to your project using Swift Package Manager. This involves adding the repository URL to your Xcode project's Package Dependencies. ```swift https://github.com/apivideo/api.video-swift-player ``` ```swift dependencies: [ .package(url: "https://github.com/apivideo/api.video-swift-player.git", from: "1.3.0"), ] ``` -------------------------------- ### Submitting an Enhancement Suggestion Source: https://github.com/apivideo/api.video-swift-player/blob/main/CONTRIBUTING.md Guidelines for suggesting enhancements or new features for the api.video Swift Player. This involves creating GitHub issues with a clear title, step-by-step descriptions, examples, current vs. expected behavior, and justification for the enhancement. ```markdown Use a clear and descriptive title for the issue to identify the suggestion. Provide a step-by-step description of the suggested enhancement in as many details as possible. Provide specific examples to demonstrate the steps. Include copy/pasteable snippets which you use in those examples, as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). Describe the current behavior and explain which behavior you expected to see instead and why. Include screenshots which help you demonstrate the steps or point out the part of api.video which the suggestion is related to. Explain why this enhancement would be useful to most api.video users and isn't something that can or should be implemented as a community package. Specify which version of the api.video package you're using. Specify the name and version of the OS you're using. ``` -------------------------------- ### Submitting a Bug Report Source: https://github.com/apivideo/api.video-swift-player/blob/main/CONTRIBUTING.md Guidelines for reporting bugs in the api.video Swift Player. This includes using GitHub issues, providing detailed steps to reproduce the bug, specific examples, observed vs. expected behavior, and environment details. ```markdown Use a clear and descriptive title for the issue to identify the problem. Describe the exact steps which reproduce the problem in as many details as possible. When listing steps, don't just say what you did, but explain how you did it. Provide specific examples to demonstrate the steps. Include links to files or GitHub projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). Describe the behavior you observed after following the steps and point out what exactly is the problem with that behavior. Explain which behavior you expected to see instead and why. Include screenshots or videos which show you following the described steps and clearly demonstrate the problem. If the problem wasn't triggered by a specific action, describe what you were doing before the problem happened and share more information using the guidelines below. Did the problem start happening recently (e.g. after updating to a new version of api.video) or was this always a problem? If the problem started happening recently. Can you reliably reproduce the issue? If not, provide details about how often the problem happens and under which conditions it normally happens. Which version of the api.video package are you using? What's the name and version of the OS you're using? ``` -------------------------------- ### Instantiate ApiVideoPlayerView Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Creates an instance of ApiVideoPlayerView, configuring it with video options for VOD or private videos. ```swift let playerView: ApiVideoPlayerView = ApiVideoPlayerView(frame: .zero, videoOptions: VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod)) // for private video VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod, token: "YOUR_PRIVATE_VIDEO_TOKEN") ``` -------------------------------- ### Import api.video Swift Player Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Imports the necessary api.video player library into your Swift project. ```swift import ApiVideoPlayer ``` -------------------------------- ### Implement PlayerDelegate Protocol Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Implements the PlayerDelegate protocol to handle various player events such as preparation, playback status, seeking, and errors. ```swift extension YourViewController: PlayerDelegate { public func didPrepare() { // Do what you want when didPrepare is called } public func didReady() { // Do what you want when didReady is called } public func didPause() { // Do what you want when didPause is called } public func didPlay() { // Do what you want when didPlay is called } public func didReplay() { // Do what you want when didReplay is called } public func didMute() { // Do what you want when didMute is called } public func didUnMute() { // Do what you want when didUnMute is called } public func didLoop() { // Do what you want when didLoop is called } public func didSetVolume(_: Float) { // Do what you want when didSetVolume is called } public func didSeek(_: CMTime, _: CMTime) { // Do what you want when didSeek is called } public func didEnd() { // Do what you want when didEnd is called } public func didError(_: Error) { // Do what you want when didError is called } public func didVideoSizeChanged(_: CGSize) { // Do what you want when didVideoSizeChanged is called } } ``` -------------------------------- ### Git Commit Message Conventions Source: https://github.com/apivideo/api.video-swift-player/blob/main/CONTRIBUTING.md Follows conventions for writing clear and informative Git commit messages, including using the present tense, limiting line length, referencing issues, and using applicable emojis to categorize changes. ```git # Use the present tense ("Add feature" not "Added feature") # Limit the first line to 72 characters or less # Reference issues and pull requests after the first line # Consider starting the commit message with an applicable emoji: # :art: when improving the format/structure of the code # :racehorse: when improving performance # :non-potable_water: when plugging memory leaks # :memo: when writing docs # :penguin: when fixing something on Linux # :apple: when fixing something on macOS # :checkered_flag: when fixing something on Windows # :bug: when fixing a bug # :fire: when removing code or files # :green_heart: when fixing the CI build # :white_check_mark: when adding tests # :lock: when dealing with security # :arrow_up: when upgrading dependencies # :arrow_down: when downgrading dependencies # :shirt: when removing linter warnings ``` -------------------------------- ### Issue and Pull Request Labels Source: https://github.com/apivideo/api.video-swift-player/blob/main/CONTRIBUTING.md Provides a comprehensive list of labels used within api.video repositories to categorize and track issues and pull requests, including their descriptions and links to GitHub search queries. ```APIDOC Issue and Pull Request Labels: Type of issue and issue state: | Label name | `apivideo` :mag_right: | Description | | --- | --- | --- | | `enhancement` | [search][search-apivideo-org-label-enhancement] | Feature requests. | | `bug` | [search][search-apivideo-org-label-bug] | Confirmed bugs or reports that are very likely to be bugs. | | `question` | [search][search-apivideo-org-label-question] | Questions more than bug reports or feature requests (e.g. how do I do X). | | `feedback` | [search][search-apivideo-org-label-feedback] | General feedback more than bug reports or feature requests. | | `help-wanted` | [search][search-apivideo-org-label-help-wanted] | The api.video team would appreciate help from the community in resolving these issues. | | `more-information-needed` | [search][search-apivideo-org-label-more-information-needed] | More information needs to be collected about these problems or feature requests (e.g. steps to reproduce). | | `needs-reproduction` | [search][search-apivideo-org-label-needs-reproduction] | Likely bugs, but haven't been reliably reproduced. | | `blocked` | [search][search-apivideo-org-label-blocked] | Issues blocked on other issues. | | `duplicate` | [search][search-apivideo-org-label-duplicate] | Issues which are duplicates of other issues, i.e. they have been reported before. | | `wontfix` | [search][search-apivideo-org-label-wontfix] | The api.video team has decided not to fix these issues for now, either because they're working as intended or for some other reason. | | `invalid` | [search][search-apivideo-org-label-invalid] | Issues which aren't valid (e.g. user errors). | | `package-idea` | [search][search-apivideo-org-label-package-idea] | Feature request which might be good candidates for new packages, instead of extending api.video packages. | | `wrong-repo` | [search][search-apivideo-org-label-wrong-repo] | Issues reported on the wrong repository. | ``` -------------------------------- ### API Video Swift Player Pull Request Labels Source: https://github.com/apivideo/api.video-swift-player/blob/main/CONTRIBUTING.md This section details the various labels used for pull requests within the API Video Swift Player project. Each label is associated with a specific stage or characteristic of a pull request and includes a link to a GitHub search query for related pull requests. ```APIDOC Pull Request Labels: - work-in-progress: Pull requests which are still being worked on, more changes will follow. Search: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Awork-in-progress - needs-review: Pull requests which need code review, and approval from maintainers or api.video team. Search: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Aneeds-review - under-review: Pull requests being reviewed by maintainers or api.video team. Search: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Aunder-review - requires-changes: Pull requests which need to be updated based on review comments and then reviewed again. Search: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Arequires-changes - needs-testing: Pull requests which need manual testing. Search: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Aneeds-testing - enhancement: Issues or pull requests related to adding new features. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aenhancement - bug: Issues or pull requests reporting a bug. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Abug - question: Issues or pull requests seeking clarification or information. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aquestion - feedback: Issues or pull requests providing feedback. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Afeedback - help-wanted: Issues or pull requests where community contributions are welcome. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Ahelp-wanted Search (sorted by comments): https://github.com/search?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted+user%3Aapivideo+sort%3Acomments-desc - more-information-needed: Issues or pull requests that require additional details from the reporter. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Amore-information-needed - needs-reproduction: Issues or pull requests that cannot be reproduced without more information. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aneeds-reproduction - windows: Issues or pull requests specific to the Windows platform. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Awindows - linux: Issues or pull requests specific to the Linux platform. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Alinux - mac: Issues or pull requests specific to the macOS platform. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Amac - documentation: Issues or pull requests related to documentation. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Adocumentation - performance: Issues or pull requests related to performance optimization. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aperformance - security: Issues or pull requests related to security vulnerabilities or fixes. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Asecurity - ui: Issues or pull requests related to the user interface. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aui - api: Issues or pull requests related to the API. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aapi - blocked: Issues or pull requests that are currently blocked. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Ablocked - duplicate: Issues or pull requests that are duplicates of existing ones. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aduplicate - wontfix: Issues or pull requests that will not be fixed. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Awontfix - invalid: Issues or pull requests that are considered invalid. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Ainvalid - package-idea: Issues or pull requests suggesting new package ideas. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Apackage-idea - wrong-repo: Issues or pull requests submitted to the incorrect repository. Search: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Awrong-repo ``` -------------------------------- ### UIKit Player Integration Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Documentation.md This section details the integration of the api.video player using UIKit, focusing on the ApiVideoPlayerView and the PlayerDelegate protocol for handling player events. ```swift import ApiVideoPlayer // Example usage of ApiVideoPlayerView let playerView = ApiVideoPlayerView() // Configure playerView with video URL, etc. // Example implementation of PlayerDelegate class MyPlayerDelegate: PlayerDelegate { func playerDidPlay(_ player: ApiVideoPlayer) { print("Player started playing") } func playerDidPause(_ player: ApiVideoPlayer) { print("Player paused") } // ... other delegate methods } let player = ApiVideoPlayer() player.delegate = MyPlayerDelegate() // Configure player with video URL, etc. ``` -------------------------------- ### Enable Fullscreen Support Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Assigns the view controller to the player view to enable fullscreen functionality. ```swift override func viewDidAppear(_ animated: Bool) { ... playerView.viewController = self } ``` -------------------------------- ### Play api.video with AVPlayer using Swift Extensions Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Utilizes Swift extensions to play api.video content directly within an existing AVPlayer instance. ```swift let videoOptions = VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod)) // for private video VideoOptions(videoId: "YOUR_VIDEO_ID", videoType: .vod, token: "YOUR_PRIVATE_VIDEO_TOKEN") val player = AVPlayer() // You already have that in your code avPlayer.replaceCurrentItem(withHls: videoOptions) ``` -------------------------------- ### SwiftUI Player Integration Source: https://github.com/apivideo/api.video-swift-player/blob/main/Sources/Documentation.docc/Documentation.md This section covers the integration of the api.video player using SwiftUI, utilizing the ApiVideoPlayer struct and the PlayerEvents enum for managing player states and events. ```swift import ApiVideoPlayer import SwiftUI // Example usage of ApiVideoPlayer in SwiftUI struct VideoView: View { var body: some View { ApiVideoPlayer(videoUrl: "YOUR_VIDEO_URL") .onEvent { event in switch event { case .play: print("SwiftUI Player played") case .pause: print("SwiftUI Player paused") case .ended: print("SwiftUI Player ended") default: break } } } } ``` -------------------------------- ### Register Player Delegate Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Registers the view controller as a delegate for the player to receive event callbacks. ```swift override func viewDidLoad() { ... self.playerView.addDelegate(self) } ``` -------------------------------- ### Use ApiVideoPlayerController with AVPlayerViewController Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Integrates the api.video player with AVKit's AVPlayerViewController for a native player experience. ```swift // Create the api.video controller let controller = ApiVideoPlayerController( videoOptions: VideoOptions(videoId: "vi77Dgk0F8eLwaFOtC5870yn", videoType: .vod), delegates: [], autoplay: false ) // Create the AVKit AVPlayerViewController let viewController = AVPlayerViewController() /// Pass the api.video controller to the AVKit AVPlayerViewController viewController.setApiVideoPlayerController(controller) // Prepare the view self.addChild(viewController) view.addSubview(viewController.view) // Set the AVKit AVPlayerViewController frame size according to your needs (here it's the whole screen) viewController.view.frame = self.view.frame // Do what you want with the video controller (play, pause, seek,...) controller.play() ``` -------------------------------- ### Enable Remote Control Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Enables the remote control functionality for the player, allowing control via external devices. Set to false to disable. ```swift override func viewDidLoad() { ... self.playerView.enableRemoteControl = true } ``` -------------------------------- ### Add Player View as Subview Source: https://github.com/apivideo/api.video-swift-player/blob/main/README.md Adds the ApiVideoPlayerView as a subview to your view controller's hierarchy. ```swift override func viewDidLoad() { ... self.addSubview(playerView) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.