Skip to content

Commit

Permalink
[Examples] Move show player button to navigation bar right
Browse files Browse the repository at this point in the history
  • Loading branch information
isair committed Dec 8, 2015
1 parent c408e04 commit 5b8e304
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions MobilePlayerExamples/ConfigExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import MobilePlayer

class ConfigExampleViewController: ExampleViewController {

init() {
super.init(nibName: nil, bundle: nil)
override init() {
super.init()
title = "Configuration"
codeImageView.image = UIImage(named: "ConfigExampleCode")
}
Expand Down
17 changes: 9 additions & 8 deletions MobilePlayerExamples/ExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ import UIKit

class ExampleViewController: UIViewController {
let codeImageView = UIImageView(frame: CGRectZero)
let showButton = UIButton(type: .System)
let videoURL = NSURL(string: "https://movielalavideos.blob.core.windows.net/videos/563cb51788b8c6db4b000376.mp4")!
let videoTitle = "Star Wars: Episode VII - The Force Awakens - International Trailer"

init() {
super.init(nibName: nil, bundle: nil)
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Show Player", style: .Plain, target: self, action: "showButtonDidGetTapped")
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor(red: 0.11, green: 0.11, blue: 0.11, alpha: 1)
view.addSubview(codeImageView)
showButton.setTitle("Show Player", forState: .Normal)
showButton.addTarget(self, action: "showButtonDidGetTapped", forControlEvents: .TouchUpInside)
view.addSubview(showButton)
}

override func viewWillLayoutSubviews() {
Expand All @@ -29,10 +34,6 @@ class ExampleViewController: UIViewController {
codeImageView.sizeToFit()
codeImageView.frame.origin.x = (size.width - codeImageView.frame.size.width) / 2
codeImageView.frame.origin.y = (size.height - codeImageView.frame.size.height) / 2
showButton.sizeToFit()
codeImageView.frame.origin.y -= (showButton.frame.size.height + 8) / 2;
showButton.frame.origin.x = (size.width - showButton.frame.size.width) / 2
showButton.frame.origin.y = codeImageView.frame.origin.y + codeImageView.frame.size.height + 8
}

func showButtonDidGetTapped() {
Expand Down
4 changes: 2 additions & 2 deletions MobilePlayerExamples/PlainExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import MobilePlayer

class PlainExampleViewController: ExampleViewController {

init() {
super.init(nibName: nil, bundle: nil)
override init() {
super.init()
title = "Plain"
codeImageView.image = UIImage(named: "PlainExampleCode")
}
Expand Down
6 changes: 3 additions & 3 deletions MobilePlayerExamples/RemoteConfigExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import MobilePlayer

class RemoteConfigExampleViewController: ExampleViewController {

init() {
super.init(nibName: nil, bundle: nil)
override init() {
super.init()
title = "Remote Configuration"
codeImageView.image = UIImage(named: "RemoteConfigExampleCode")
}
Expand All @@ -26,7 +26,7 @@ class RemoteConfigExampleViewController: ExampleViewController {
let playerVC = MobilePlayerViewController(
contentURL: videoURL,
config: MobilePlayerConfig(fileURL: configURL))
playerVC.title = "Remote Player - \(videoTitle)"
playerVC.title = "Watermarked Player - \(videoTitle)"
playerVC.activityItems = [videoURL]
presentMoviePlayerViewControllerAnimated(playerVC)
}
Expand Down

0 comments on commit 5b8e304

Please sign in to comment.