Skip to content

A feature-rich video player with custom playback controls, subtitle and video quality selection, live streaming, and robust error handling.

License

Notifications You must be signed in to change notification settings

ajkmr7/Custom-Video-Player

Repository files navigation

Custom Video Player

A feature-rich video player with custom playback controls, subtitle and video quality selection, live streaming, and robust error handling.

Features

  • Custom Playback Controls
  • Video Playlist
  • Subtitle Selection
  • Video Quality Selection
  • Live Stream Support
  • Error Handling

Requirements

  • iOS 11.0 or later

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Custom Video Player into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target '<Your Target Name>' do
   pod 'CustomVideoPlayer', :git => 'https://github.com/ajkmr7/Custom-Video-Player.git', :tag => '1.1.0'
end

Then, run the following command:

$ pod install

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

To integrate Custom Video Player into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "https://github.com/ajkmr7/Custom-Video-Player.git", from: "1.1.0")
]

Usage

Initialize and configure the player with a video playlist. The playlist should have a title and a list of videos, with each video having its own title, URL, and isLiveContent attribute.

let playlist = VideoPlaylist(
   title: "IPTV",
   videos: [
      Video(
            url: "https://ndtvindiaelemarchana.akamaized.net/hls/live/2003679/ndtvindia/master.m3u8",
            title: "NDTV",
            isLiveContent: true
      ),
      Video(
            url: "https://segment.yuppcdn.net/050522/murasu/050522/murasu_1200/chunks.m3u8",
            title: "Murasu",
            isLiveContent: true
      ),
      Video(
            url: "https://ndtv24x7elemarchana.akamaized.net/hls/live/2003678/ndtv24x7/[email protected]",
            title: "NDTV.com",
            isLiveContent: true
      ),
   ]
)
let config = VideoPlayerConfig(playlist: playlist)

Initialize the VideoPlayerCoordinator with your base UINavigationController and invoke the player with the configuration.

let coordinator = VideoPlayerCoordinator(navigationController: navigationController)
coordinator.invoke(videoPlayerConfig: config)

Sample App

To see a working implementation of the Custom Video Player, you can use the Example app provided in the repository. Follow these steps to set it up:

  1. Clone this repository.

    git clone https://github.com/ajkmr7/Custom-Video-Player.git
  2. Navigate to the Example directory and install the necessary pods.

    cd Custom-Video-Player/Example
    pod install
  3. Open the workspace in Xcode.

    open Custom-Video-Player.xcworkspace
  4. Build and run the project on your device or simulator.

Sample Use Case: Watch Party

We have a branch with a sample use case demonstrating how to implement a Watch Party feature. Check out the watch-party branch to see this in action.

Articles for Further Implementation

For more detailed guidance on customizing and extending the player, refer to the following articles: