Git Product home page Git Product logo

swifty360player's Introduction

Build Status CocoaPods Compatible Carthage Compatible License

Swifty360Player Swifty360Player

iOS 360-degree video player streaming from an AVPlayer.

Demo

Swifty360Player Demo

Requirements

Swifty360Player Version Minimum iOS Target Swift Version
0.2.5 11.0 5.x
0.2.2 11.0 4.2
0.2.1 10.0 4.1
0.2 10.0 4.0

CocoaPods

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

$ gem install cocoapods

To integrate Swifty360Player 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 'Swifty360Player', '0.2.5'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

brew update
brew install carthage

To integrate Swifty360Player into your Xcode project using Carthage, specify it in your Cartfile:

github "abdullahselek/Swifty360Player" ~> 0.2.5

Run carthage update to build the framework and drag the built Swifty360Player.framework into your Xcode project.

Swift Package Manager

Modify your Package.swift file to include the following dependency:

.package(url: "https://github.com/abdullahselek/Swifty360Player.git", from: "0.2.5")

Run swift package resolve

XCFramework

XCFrameworks require Xcode 11 or later and integration is very similar to integration of .framework format. Please use script scripts/build-framework.sh to generate binary Swifty360Player.xcframework archive that you can use as a dependency in Xcode.

Swifty360Player.xcframework is a Release (Optimized) binary that offer best available Swift code performance.

Example Usage

You just need an AVPlayer instance created with a valid video url and a Swifty360MotionManager instance. You can use these code snippets in a UIViewController instance.

Video url can be either local or remote.

let videoURL = URL(fileURLWithPath: Bundle.main.path(forResource: "google-help-vr", ofType: "mp4")!)
let player = AVPlayer(url: videoURL)

let motionManager = Swifty360MotionManager.shared
swifty360ViewController = Swifty360ViewController(withAVPlayer: player, motionManager: motionManager)

addChildViewController(swifty360ViewController)
view.addSubview(swifty360ViewController.view)
swifty360ViewController.didMove(toParentViewController: self)

player.play()

let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(reorientVerticalCameraAngle))
view.addGestureRecognizer(tapGestureRecognizer)

Tap Gesture Handler

@objc func reorientVerticalCameraAngle() {
    swifty360ViewController.reorientVerticalCameraAngleToHorizon(animated: true)
}

Using storyboard and Swifty360ViewController as parent class

guard let swifty360ViewController = self.storyboard?.instantiateViewController(withIdentifier: "TestViewController") as? TestViewController else {
    return
}
let videoURL = URL(fileURLWithPath: Bundle.main.path(forResource: "google-help-vr", ofType: "mp4")!)
let player = AVPlayer(url: videoURL)
let motionManager = Swifty360MotionManager.shared
swifty360ViewController.player = player
swifty360ViewController.motionManager = motionManager
self.present(swifty360ViewController, animated: true, completion: nil)
import UIKit
import Swifty360Player

class TestViewController: Swifty360ViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        player.play()
    }

}

Example use of Swifty360View with using code commands

let videoURL = URL(fileURLWithPath: Bundle.main.path(forResource: "google-help-vr", ofType: "mp4")!)
let player = AVPlayer(url: videoURL)

let motionManager = Swifty360MotionManager.shared

let swifty360View = Swifty360View(withFrame: view.bounds,
                                  player: player,
                                  motionManager: motionManager)
swifty360View.setup(player: player, motionManager: motionManager)
view.addSubview(swifty360View)

player.play()

Using Swifty360View with Storyboard

  • Add a UIView to your viewcontroller and change it's class as Swifty360View
  • Connect via IBOutlets

and

let videoURL = URL(fileURLWithPath: Bundle.main.path(forResource: "google-help-vr", ofType: "mp4")!)
let player = AVPlayer(url: videoURL)

let motionManager = Swifty360MotionManager.shared

swifty360View.setup(player: player, motionManager: motionManager)

player.play()

Tap gesture recognizers for Swifty360View, create one recognizer for your viewcontroller's view

let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(reorientVerticalCameraAngle))
view.addGestureRecognizer(tapGestureRecognizer)

and selector function

@objc func reorientVerticalCameraAngle() {
    swifty360View.reorientVerticalCameraAngleToHorizon(animated: true)
}

License

Swifty360Player is released under the MIT license. See LICENSE for details.

swifty360player's People

Contributors

abdullahselek avatar dependabot[bot] avatar and01 avatar danialepaco avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.