All Projects → ustwo → Videoplayback Ios

ustwo / Videoplayback Ios

Licence: mit
Swift AVPlayer wrapper using the VIPER architecture. Currently a work in progress

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Videoplayback Ios

Sjvideoplayer
iOS VideoPlayer MediaPlayer video player media player 短视频播放器 可接入 ijkplayer aliplayer alivodplayer plplayer
Stars: ✭ 2,066 (+869.95%)
Mutual labels:  avplayer
L5modular
Generates and handles Modules for Laravel
Stars: ✭ 188 (-11.74%)
Mutual labels:  modules
Bit
A tool for component-driven application development.
Stars: ✭ 14,443 (+6680.75%)
Mutual labels:  modules
Android Clean Architecture
Showcasing a Clean Architecture approach from our Android applications framework!
Stars: ✭ 160 (-24.88%)
Mutual labels:  modules
Modernavplayer
ModernAVPlayer is a persistence AVPlayer wrapper
Stars: ✭ 179 (-15.96%)
Mutual labels:  avplayer
Zhuishushenqi
追书神器Swift版客户端(非官方)。 不断更新中......
Stars: ✭ 196 (-7.98%)
Mutual labels:  viper
Vuex Namespaced Module Structure
📈 A Vue.js project powered by Vuex namespaced modules in a simple structure based on Large-scale Vuex application structures
Stars: ✭ 146 (-31.46%)
Mutual labels:  modules
Marshroute
Marshroute is an iOS Library for making your Routers simple but extremely powerful
Stars: ✭ 208 (-2.35%)
Mutual labels:  viper
Fradioplayer
A simple radio player framework for iOS, macOS, tvOS.
Stars: ✭ 183 (-14.08%)
Mutual labels:  avplayer
M2
The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
Stars: ✭ 200 (-6.1%)
Mutual labels:  modules
Swiftaudio
Audio player for iOS
Stars: ✭ 160 (-24.88%)
Mutual labels:  avplayer
Lyricsanalysis
iOS音乐播放器之锁屏效果(仿网易云音乐和QQ音乐)+歌词解析 :锁屏歌曲信息、控制台远程控制音乐播放:暂停/播放、上一首/下一首、快进/快退、列表菜单弹框和拖拽控制台的进度条调节进度(结合了QQ音乐和网易云音乐在锁屏状态下的效果)、歌词解析并随音乐滚动显示。
Stars: ✭ 169 (-20.66%)
Mutual labels:  avplayer
Currency Converter Swift3.0 Viper
Calculates money quick and easy way to see live foreign exchange rates (Based on swift 4.2, viper architecture and special thanks to https://github.com/hakanensari/fixer-io for conversion API)
Stars: ✭ 198 (-7.04%)
Mutual labels:  viper
Ndash
your npm dashboard! (react-native app)
Stars: ✭ 158 (-25.82%)
Mutual labels:  modules
Browserify
browser-side require() the node.js way
Stars: ✭ 13,929 (+6439.44%)
Mutual labels:  modules
Httpimport
Module for remote in-memory Python package/module loading through HTTP/S
Stars: ✭ 153 (-28.17%)
Mutual labels:  modules
Beginners Python Examples
Basic Python CLI programs
Stars: ✭ 190 (-10.8%)
Mutual labels:  modules
Videoplayer
📽 A video player for SwiftUI, support for caching, preload and custom control view. SwiftUI 视频播放器,支持边下边播、预加载、自定义控制层
Stars: ✭ 212 (-0.47%)
Mutual labels:  avplayer
Gitpkg
Publish packages as git tags
Stars: ✭ 208 (-2.35%)
Mutual labels:  modules
Hcdcacheplayer
A video player with cache.
Stars: ✭ 198 (-7.04%)
Mutual labels:  avplayer

license pod pod

Summary

This framework is built using the VIPER (modified to VIPE) architecture. It started as an experiment with the architecture itself and is now a work in progress.

It is a swift wrapper around the AVFoundation framework. Use it to play remote, or local videos in a simple view or feed. Its purpose is to make playing progressive downloads and live streams simpler in your iOS applications

We also wrote a blog post on VIPER itself here: https://ustwo.com/blog/ins-and-outs-of-viper

Disclaimer:

This framework is a work in progress. Unit tests, VIPE refactoring, and bug fixes are pending.

Features

  • [x] Scrub Video
  • [x] Handle play or stop video in main thread
  • [x] Play in UITableView
  • [x] Autoplay video
  • [x] HTTPS support
  • [x] Written in Swift
  • [x] Landscape support
  • [x] Cocoapod support

Requirements

  • iOS 10.0 or later
  • Xcode 8.3 or later

Getting Started

  • Go to the "DemoVideoPlaybackKit" folder, run pod install. Open the workspace and build

About

The VIPER architecture has been talked about in the iOS community; however, it is uncommonly used. We wanted to gain an in depth understanding of this design pattern and see what the buzz was all about. As a result, we decided to test the following hypothesis:

As a developer I would like to use the VIPER design pattern to build reusable modules

We then decided to experiment with VIPER & playing video content. Playing video involves UI updates, data downloading & data syncrhonization. These complexities & interactions proved themselves to be worthwhile candidate for a VIPER structured module.

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

  • pod install 'VideoPlaybackKit'

How To Use

import VideoPlaybackKit

Play a single video in a view - add a single view to your screen which contains video content

  1. Define the Video Type (local or remote). This is the ENTITY represented in the VIPER structure
let videoType = VPKVideoType.local(videoPathName: "Elon_Musk", fileType: "mp4", placeholderImageName: "elon_1")
  1. Build the video view
VPKVideoPlaybackBuilder.vpk_buildVideoView(for: videoType, shouldAutoplay: self.shouldAutoPlay, playbackBarTheme: self.toolBarTheme) { [weak self] (videoView) in

        self?.view.addSubview(videoView)
        videoView.snp.makeConstraints({ (make) in
        make.height.equalTo(self?.view.snp.height).dividedBy(2)
        make.top.equalTo(self?.view.snp.top).offset(10)
        make.left.right.equalTo(self?.view)
    })
}

Play a video in a feed

  1. Create a UITabieViewCell that conforms to VPKViewInCellProtocol
class VideoTableViewCell: UITableViewCell, VPKViewInCellProtocol {
    static let identifier = "VideoCell"
    var videoView: VPKVideoView? {
        didSet {
            self.setupVideoViewConstraints()
            layoutIfNeeded()
        }
    }
    
    override func prepareForReuse() {
        super.prepareForReuse()
        prepareForVideoReuse() //Extension default
    }
}
  1. Register cell in UIViewController, set up tableview. Add videoview to cell
    tableView.register(VideoTableViewCell.self, forCellReuseIdentifier: VideoTableViewCell.identifier)
    tableView.estimatedRowHeight = 400
    tableView.rowHeight = UITableViewAutomaticDimension

    datasource.asObservable().bind(to: tableView.rx.items(cellIdentifier: VideoTableViewCell.identifier)) { index, model, cell in
            
        guard let cell = cell as? VideoTableViewCell else { return }

        VPKVideoPlaybackBuilder.vpk_buildViewInCell(for: model, at: NSIndexPath(item: index, section: 0), completion: { [weak self] (videoView) in
                cell.videoView = videoView
                cell.layoutIfNeeded()
        })}.addDisposableTo(disposeBag)

        tableView.rx.setDelegate(self)
}

Autoplay Videos in a feed

  1. Conform to the VPKTableViewVideoPlaybackScrollable protocol

Implement the following:

extension FeedViewController: VPKTableViewVideoPlaybackScrollable {

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        handleAutoplayInTopVideoCell() // default implementation
        trackVideoViewCellScrolling() // default implementation
    }   

    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        if shouldAutoplayVideos {
            handleAutoplayInTopVideoCell()
        }
    }
}

Play video in feed, pre-fetch video asset data. *** Recommended especially for auto playing video in a feed ***

  1. Create a VPKTableViewPrefetchSynchronizer object
videoPrefetcher = VPKTableViewPrefetchSynchronizer(videoItems: datasource.value)
  1. Conform to the UITableViewDataSourcePrefetching tableview protocool
tableView.prefetchDataSource = self

extension FeedViewController: UITableViewDataSourcePrefetching {

    func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
        videoPrefetcher?.tableView(tableView, prefetchRowsAt: indexPaths)
    }

    func tableView(_ tableView: UITableView, cancelPrefetchingForRowsAt indexPaths: [IndexPath]) {
        videoPrefetcher?.tableView(tableView, cancelPrefetchingForRowsAt: indexPaths)
    }
}

Contact:

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].