All Projects → wxxsw → Gsplayer

wxxsw / Gsplayer

Licence: mit
⏯ Video player, support for caching, preload, fullscreen transition and custom control view. 视频播放器,支持边下边播、预加载、全屏转场和自定义控制层

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Gsplayer

Ivid
🔴 (cyoa) interactive video player 🔵
Stars: ✭ 122 (-15.28%)
Mutual labels:  player
Shuffle
Shuffle every song in existence from YouTube
Stars: ✭ 131 (-9.03%)
Mutual labels:  player
Yinyuetaiplayer
高仿音悦台播放页面效果
Stars: ✭ 140 (-2.78%)
Mutual labels:  player
Oarplayer
Android Rtmp播放器,基于MediaCodec与srs-librtmp,不依赖ffmpeg
Stars: ✭ 124 (-13.89%)
Mutual labels:  player
Asciiplayer
📺 ASCII gif/video player write in golang
Stars: ✭ 130 (-9.72%)
Mutual labels:  player
Dplayer
🍭 Wow, such a lovely HTML5 danmaku video player
Stars: ✭ 12,101 (+8303.47%)
Mutual labels:  player
Vue Netease Music
🎵 基于 Vue2、Vue-CLI3 的高仿网易云 mac 客户端播放器(PC) Online Music Player
Stars: ✭ 1,783 (+1138.19%)
Mutual labels:  player
Musicplayer
A minimal music player built on electron.
Stars: ✭ 145 (+0.69%)
Mutual labels:  player
React Dplayer
react-dplayer
Stars: ✭ 130 (-9.72%)
Mutual labels:  player
Asciinema Player
asciinema player is an open-source terminal session player written in Javascript and Rust/WASM. Unlike other video players asciinema player doesn't play heavy-weight video files (.mp4, .webm etc) and instead plays light-weight terminal session files called asciicasts.
Stars: ✭ 1,948 (+1252.78%)
Mutual labels:  player
Favesound Redux
🎶 A SoundCloud Client in React + Redux running in production. Live Demo and Source Code to explore React + Redux as a beginner.
Stars: ✭ 1,586 (+1001.39%)
Mutual labels:  player
Rxmusicplayer Android
An android music player using ExoPlayer and RxJava2
Stars: ✭ 127 (-11.81%)
Mutual labels:  player
Pragha
Pragha is a Lightweight Music Player for GNU/Linux.
Stars: ✭ 136 (-5.56%)
Mutual labels:  player
Osu Player
A multifunctional media player for osu and osuer. Modern interface with WPF.
Stars: ✭ 123 (-14.58%)
Mutual labels:  player
Player
▶️ video player in Swift, simple way to play and stream media on iOS/tvOS
Stars: ✭ 1,849 (+1184.03%)
Mutual labels:  player
Persistentstreamplayer
Stream audio over http, and persist the data to a local file while buffering
Stars: ✭ 120 (-16.67%)
Mutual labels:  player
Html5 Dash Hls Rtmp
🌻 HTML5播放器、M3U8直播/点播、RTMP直播、低延迟、推流/播流地址鉴权
Stars: ✭ 1,805 (+1153.47%)
Mutual labels:  player
React Native Sound Player
Play sound file in ReactNative
Stars: ✭ 144 (+0%)
Mutual labels:  player
Timecat
A Magical Web Recorder & Player 🖥
Stars: ✭ 1,955 (+1257.64%)
Mutual labels:  player
Chameleon
Chameleon is a flexible media player build with Xamarin.Forms
Stars: ✭ 137 (-4.86%)
Mutual labels:  player

GSPlayer

Features

  • [x] Fully customizable UI.
  • [x] Easy to use API and callbacks.
  • [x] Built-in caching mechanism to support playback while downloading (mp4).
  • [x] Can preload multiple videos at any time.
  • [x] Can be embedded into UITableView and UICollectionView.
  • [x] Provide full screen transition.
  • [ ] Complete Demo.

Quick Start

  1. Add VideoPlayerView to the interface.
let playerView = VideoPlayerView()
view.addSubview(playerView)

// Or in IB, specify the type of custom View as VideoPlayerView.
  1. Play Video.
playerView.play(for: someURL)
  1. Pause/Resume Video.
if playerView.state == .playing {
    playerView.pause(reason: .userInteraction)
} else {
    playerView.resume()
}
  1. Update control UI based on playback status.
playerView.stateDidChanged = { state in
    switch state {
    case .none:
        print("none")
    case .error(let error):
        print("error - \(error.localizedDescription)")
    case .loading:
        print("loading")
    case .paused(let playing, let buffering):
        print("paused - progress \(Int(playing * 100))% buffering \(Int(buffering * 100))%")
    case .playing:
        print("playing")
    }
}

Documents

Cache

Get the total size of the video cache.

VideoCacheManager.calculateCachedSize()

Clean up all caches.

VideoCacheManager.cleanAllCache()

Preload

Set the video URL to be preloaded. Preloading will automatically cache a short segment of the beginning of the video and decide whether to start or pause the preload based on the buffering of the currently playing video.

VideoPreloadManager.shared.set(waiting: [URL])

Set the preload size, the default value is 1024 * 1024, unit is byte.

VideoPlayer.preloadByteCount = 1024 * 1024 // = 1M

Fullscreen

See demo.

PlayerView

Property

An object that manages a player's visual output.

public let playerLayer: AVPlayerLayer { get }

Get current video status.

public enum State {

    /// None
    case none

    /// From the first load to get the first frame of the video
    case loading

    /// Playing now
    case playing

    /// Pause, will be called repeatedly when the buffer progress changes
    case paused(playing: Double, buffering: Double)

    /// An error occurred and cannot continue playing
    case error(NSError)
}

public var state: State { get }

The reason the video was paused.

public enum PausedReason {

    /// Pause because the player is not visible, stateDidChanged is not called when the buffer progress changes
    case hidden

    /// Pause triggered by user interaction, default behavior
    case userInteraction

    /// Waiting for resource completion buffering
    case waitingKeepUp
}

public var pausedReason: PausedReason { get }

Number of replays.

public var replayCount: Int { get }

Played progress, value range 0-1.

public var playing: Double { get }

Played length in seconds.

public var currentDuration: Double { get }

Buffered progress, value range 0-1.

public var buffering: Double { get }

Buffered length in seconds.

public var currentBufferDuration: Double { get }

Total video duration in seconds.

public var totalDuration: Double { get }

The total watch time of this video, in seconds.

public var watchDuration: Double { get }

Whether the video is muted, only for this instance.

public var isMuted: Bool { get set }

Video volume, only for this instance.

public var volume: Double { get set }

Callback

Playback status changes, such as from play to pause.

public var stateDidChanged: ((State) -> Void)?

Replay after playing to the end.

public var replay: (() -> Void)?

Method

Play a video of the specified url.

func play(for url: URL)

Pause video.

func pause(reason: PausedReason)

Continue playing video.

func resume()

Installation

GSPlayer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'GSPlayer'

Contribution

Issue

If you find a bug or need a help, you can create a issue

Pull Request

We are happy to accept pull requests :D. But please make sure it's needed by most developers and make it simple to use. If you are not sure, create an issue and we can discuss it before you get to coding.

License

The MIT License (MIT)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].