Skip to content

Sweefties/tvOS9-VideoPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tvOS 9 - New OS - Video Player tvOS! - Example

tvOS 9~ Experiments - Native AVKit VideoPlayer - appleTv.

Example

Video Source Example

current movie, watermark image from : NASA Official Videos

Requirements

  • = XCode 8.0.

  • = Swift 3.

  • = tvOS 9.0

Tested on tvOS 9.0 Simulator, Apple Tv Developer Kit.

Important

this is the Xcode 8 / Swift updated project.

App Transport Security Settings

To support HTTP hosted : add the Boolean type Value to YES for NSAllowsArbitraryLoads in app's info.plist file.

Code Example

Create a new Swift file

import Foundation
import UIKit
import AVKit

class VideoPlayerViewController: AVPlayerViewController {

    // MARK: - Properties
    let overlay = UIView(frame: CGRectMake(0, 0, 285, 225))
    let watermark = "your_image_name"
    var url = "http://www.your_url_string"

    // MARK: - Lifecycle
    override func viewDidLoad() {
        super.viewDidLoad()
        setVideoPlayer()
    }

    // MARK: - Set video player for view
    func setVideoPlayer() {
        // watermark overlay (logo tv by example..)
        overlay.addSubview(UIImageView(image: UIImage(named: watermark)))
        contentOverlayView?.addSubview(overlay)

        // AVPlayer Instance with NSURL
        player = AVPlayer(URL: NSURL(string: url)!)

        // Just Play!
        player?.play()
    }
}

Configure your storyboard with AVKit Player View Controller Object Library.

Usage

To run the example project, download or clone the repo.

About

tvOS 9~ Experiments - Native AVKit VideoPlayer - appleTv.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages