VGPlayer

Welcome to the official documentation for VGPlayer! Here you will find all the information you need to get started with VGPlayer.

Table of Contents

  1. Installation
  2. Usage
  3. Features
  4. Configuration
  5. Examples
  6. Troubleshooting
  7. Contributing
  8. License

Installation

Prerequisites

Before getting started with VGPlayer, make sure you have the following requirements:

  • Minimum iOS version 12.0
  • Xcode version 11.0 or later
  • Swift 5.0 or later

CocoaPods

Step 1: Add VGPlayer to your Podfile

Add the following line to your Podfile:


pod 'VGPlayer'

Step 2: Install VGPlayer

Run the following command in your terminal:


pod install

Manual Installation

Step 1: Download VGPlayer

Download the latest version of VGPlayer from the official GitHub repository.

Step 2: Add VGPlayer to your project

Drag and drop the VGPlayer.xcodeproj file into your project’s “Frameworks” or “Libraries” folder.

Usage

Quick Start

Follow these steps to start using VGPlayer in your project:

  1. Import VGPlayer into your View Controller:

  2. import VGPlayer

  3. Create an instance of VGPlayerView and add it to your view hierarchy:

  4. let playerView = VGPlayerView()
    view.addSubview(playerView)

  5. Load a video URL into the player:

  6. let videoURL = URL(string: "https://example.com/video.mp4")
    playerView.setVideoURL(videoURL)

  7. Play the video:

  8. playerView.play()

Features

General Features

  • Playback of local and network videos
  • Support for popular video formats (e.g., MP4, MOV)
  • Customizable player controls (play, pause, seek, volume, etc.)
  • Full-screen mode

Advanced Features

  • Adaptive streaming support (HLS, DASH)
  • Custom video source handlers for complex video URLs
  • Subtitle support
  • Playback rate control
  • Video filtering and effects

Configuration

Player Options

VGPlayer provides various options to configure the player’s behavior:

  • autoplay: Whether the video should start playing automatically (default is false)
  • loop: Whether the video should loop after reaching the end (default is false)
  • gravity: The video’s gravity/fill mode (aspectFill, aspectFit, resize, resizeAspectFill)


// Example player configuration
playerView.autoplay = true
playerView.loop = true
playerView.gravity = .aspectFill

Examples

Here are some examples showcasing different use cases of VGPlayer:

Basic Usage

Example code for basic video playback:


import VGPlayer

let playerView = VGPlayerView()
let videoURL = URL(string: "https://example.com/video.mp4")

playerView.setVideoURL(videoURL)
playerView.play()

Customization

Example code to customize the appearance of VGPlayer:


import VGPlayer

let playerView = VGPlayerView()
let videoURL = URL(string: "https://example.com/video.mp4")

// Customize player appearance
playerView.playerControlsView.backgroundColor = .black
playerView.playerControlsView.playPauseButton.tintColor = .white

playerView.setVideoURL(videoURL)
playerView.play()

Troubleshooting

If you encounter any issues while using VGPlayer, try the following troubleshooting steps:

  • Make sure you have followed the installation instructions correctly
  • Verify that your video URL is valid and accessible
  • Check the console for any error messages or warnings
  • Refer to the closed issues on the official GitHub repository
  • If the issue persists, open a new issue on the GitHub repository with details about the problem you are facing

Contributing

We welcome contributions to VGPlayer! If you would like to contribute, please follow the guidelines mentioned in the CONTRIBUTING.md file.

License

VGPlayer is released under the MIT License. For more details, refer to the LICENSE file.