Swiftpack.co -  aplr/Richi as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
aplr/Richi
A Video Player View for iOS and macOS, written in Swift.
.package(url: "https://github.com/aplr/Richi.git", from: "1.0.5")

Richi

Build Documentation

Richi is an easy-to-use video player library written in Swift, with support for iOS, tvOS and macOS. It provides you a VideoPlayer view with a simple yet powerful API, which makes playing videos a joy on iOS and macOS.

Features

Richi builds on top of AVPlayer and aims at simplifying its interface, while providing additional features such as:

► Playback events using delegates
► Time observing using delegates and Combine
► Built-In URL-based memory and disk cache (🚧 WIP)
► Header-based authentication
► Customizable asset loading
► Video snapshots

This library does NOT provide any video player UI in order to keep it as lightweight as possible, while making it highly flexible to use.

Installation

Richi is available via the Swift Package Manager which is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system and automates the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding Richi as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(
        url: "https://github.com/aplr/Richi.git",
        .upToNextMajor(from: "1.0.0")
    )
]

Usage

import Richi

class UIViewController {

    /// The video player view
    lazy var videoPlayer: VideoPlayer = {
        let view = VideoPlayer()
        view.translatesAutoresizingMaskIntoConstraints = false
        view.actionAtEnd = .loop
        view.gravity = .aspectFit
        view.autoplay = true
        return view
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Add the video player as a subview
        view.addSubview(videoPlayer)

        // Add layout constraints
        view.addConstraints([
            videoPlayer.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            videoPlayer.topAnchor.constraint(equalTo: view.topAnchor),
            videoPlayer.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            videoPlayer.bottomAnchor.constraint(equalTo: view.bottomAnchor)
        ])

        let url = URL(string: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4")!

        let asset = Richi.Asset(url: url)

        // Load the asset. Since autoplay is enabled, playback
        // will start as soon as the asset is ready to play.
        videoPlayer.load(asset: asset)
    }
}

Documentation

Documentation is available here and provides a comprehensive documentation of the library's public interface. Expect usage examples and guides to be added shortly. For now, have a look at the demo app in the Example directory.

License

Richi is licensed under the MIT License.

GitHub

link
Stars: 2
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Release Notes

Richi 1.0.5
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API