Skip to content

irons163/IRPlayerUIShell-swift

Repository files navigation

Build Status Platform

IRPlayerUIShell

Features

  • Support customize UI for IRPlayer.
  • Support some media controllers.
    • Seek Bar
    • Brightness
    • Volume
    • Full Screen
  • Has a Demo

Future

  • Support Multi video player in one page(UITableView, UICollectionView, etc).
  • More powerful custom UI design.
  • Make a framework for this project.

Install

SPM

  • Add package: https://github.com/irons163/IRPlayerUIShell-swift

Usage

Basic

  • See IRPlayerUIShellViewController for demo.

  • Create a IRPlayer instance.

import IRPlayer

// Create the decoder and PlayerImp
let playerImp: IRPlayerImp = {
    let p = IRPlayerImp.player()
    p.decoder = IRPlayerDecoder.ffmpegDecoder()
    // Single video example
    if let url = URL(string: "https://example.com/video.mp4") {
        p.replaceVideo(with: url)
    }
    return p
}()
  • Create IRPlayerController with playerManager and containerView, then set the controlView:
let containerView = UIView()
let controlView = IRPlayerControlView() // Adjust to your concrete control view type

let player = IRPlayerController.player(withPlayerManager: playerImp,
                                       containerView: containerView)
player.controlView = controlView
  • Provide multiple video URLs — the first one will auto‑play:
let assetURLs: [URL] = [
    URL(string: "https://example.com/video1.mp4")!,
    URL(string: "https://example.com/video2.mp4")!
]
player.assetURLs = assetURLs

Advanced Settings

  • Keep playing when the app resigns active (background):
player.pauseWhenAppResignActive = false
  • Listen for orientation/fullscreen changes:
player.orientationWillChange = { [weak self] (_, _) in
    self?.setNeedsStatusBarAppearanceUpdate()
}
  • Listen for when the player reaches the end of the current item:
player.playerDidToEnd = { [weak player, weak controlView] _ in
    guard let player, let controlView else { return }

    // Pause then play again (retains your original behavior)
    player.currentPlayerManager.pause()
    player.currentPlayerManager.play()

    // Play next item
    player.playTheNext()

    if !player.isLastAssetURL {
        let title = "title:\\(player.currentPlayIndex)"
        controlView.showTitle(title,
                              coverURLString: kVideoCover,
                              fullScreenMode: .landscape)
    } else {
        player.stop()
    }
}
  • More, coming soon...

Screenshots

Play Seek
Demo Demo
Volume Brightness
Demo Demo
Full Screen Lock Screen
Demo Demo

Demo

Copyright

This project is inspired from ZFPlayer.

About

IRPlayerUIShell is a powerful UI Shell framework for the video player(IRPlayer) for iOS.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages