diff --git a/KDIC.xcodeproj/project.pbxproj b/KDIC.xcodeproj/project.pbxproj index 0548790..ff7fd58 100644 --- a/KDIC.xcodeproj/project.pbxproj +++ b/KDIC.xcodeproj/project.pbxproj @@ -631,7 +631,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = "KDIC/KDIC-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.4; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "GrinnellAppDev.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -659,7 +659,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = "KDIC/KDIC-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.4; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "GrinnellAppDev.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/KDIC/Base.lproj/Main_iPhone.storyboard b/KDIC/Base.lproj/Main_iPhone.storyboard index 1d283fe..26bbbc7 100644 --- a/KDIC/Base.lproj/Main_iPhone.storyboard +++ b/KDIC/Base.lproj/Main_iPhone.storyboard @@ -1,11 +1,11 @@ - - + + - - + + @@ -19,32 +19,16 @@ - + - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + - + + + + + + diff --git a/KDIC/Base.lproj/Screen Shot 2017-03-08 at 5.54.02 PM.png b/KDIC/Base.lproj/Screen Shot 2017-03-08 at 5.54.02 PM.png new file mode 100644 index 0000000..f2d78e9 Binary files /dev/null and b/KDIC/Base.lproj/Screen Shot 2017-03-08 at 5.54.02 PM.png differ diff --git a/KDIC/Images.xcassets/Equalizer.imageset/Contents.json b/KDIC/Images.xcassets/Equalizer.imageset/Contents.json new file mode 100644 index 0000000..cf6cd1f --- /dev/null +++ b/KDIC/Images.xcassets/Equalizer.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Equalizer@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Equalizer@3x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Equalizer@2x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@1x.png b/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@1x.png new file mode 100644 index 0000000..fd7b19b Binary files /dev/null and b/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@1x.png differ diff --git a/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@2x.png b/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@2x.png new file mode 100644 index 0000000..3307094 Binary files /dev/null and b/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@2x.png differ diff --git a/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@3x.png b/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@3x.png new file mode 100644 index 0000000..db872cd Binary files /dev/null and b/KDIC/Images.xcassets/Equalizer.imageset/Equalizer@3x.png differ diff --git a/KDIC/Images.xcassets/PauseButton.imageset/Contents.json b/KDIC/Images.xcassets/PauseButton.imageset/Contents.json new file mode 100644 index 0000000..0d7b5ce --- /dev/null +++ b/KDIC/Images.xcassets/PauseButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "PauseButton @1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PauseButton @2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PauseButton @3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @1x.png b/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @1x.png new file mode 100644 index 0000000..97fe834 Binary files /dev/null and b/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @1x.png differ diff --git a/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @2x.png b/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @2x.png new file mode 100644 index 0000000..b1a9fa0 Binary files /dev/null and b/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @2x.png differ diff --git a/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @3x.png b/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @3x.png new file mode 100644 index 0000000..3bcbd70 Binary files /dev/null and b/KDIC/Images.xcassets/PauseButton.imageset/PauseButton @3x.png differ diff --git a/KDIC/Images.xcassets/PlayButton.imageset/Contents.json b/KDIC/Images.xcassets/PlayButton.imageset/Contents.json new file mode 100644 index 0000000..f167a2e --- /dev/null +++ b/KDIC/Images.xcassets/PlayButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "PlayButton @1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "PlayButton @2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "PlayButton.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/KDIC/Images.xcassets/PlayButton.imageset/PlayButton @1x.png b/KDIC/Images.xcassets/PlayButton.imageset/PlayButton @1x.png new file mode 100644 index 0000000..2739243 Binary files /dev/null and b/KDIC/Images.xcassets/PlayButton.imageset/PlayButton @1x.png differ diff --git a/KDIC/Images.xcassets/PlayButton.imageset/PlayButton @2x.png b/KDIC/Images.xcassets/PlayButton.imageset/PlayButton @2x.png new file mode 100644 index 0000000..2bafeb9 Binary files /dev/null and b/KDIC/Images.xcassets/PlayButton.imageset/PlayButton @2x.png differ diff --git a/KDIC/Images.xcassets/PlayButton.imageset/PlayButton.png b/KDIC/Images.xcassets/PlayButton.imageset/PlayButton.png new file mode 100644 index 0000000..b54f59d Binary files /dev/null and b/KDIC/Images.xcassets/PlayButton.imageset/PlayButton.png differ diff --git a/KDIC/Launch Screen.storyboard b/KDIC/Launch Screen.storyboard index 59b48a6..20e8dbc 100644 --- a/KDIC/Launch Screen.storyboard +++ b/KDIC/Launch Screen.storyboard @@ -1,7 +1,11 @@ - - + + + + + - + + @@ -13,9 +17,9 @@ - + - + diff --git a/KDIC/PlayerViewController.swift b/KDIC/PlayerViewController.swift index cafeddc..ae2426e 100644 --- a/KDIC/PlayerViewController.swift +++ b/KDIC/PlayerViewController.swift @@ -6,17 +6,23 @@ class PlayerViewController: UIViewController { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var subtitleLabel: UILabel! @IBOutlet weak var imageView: UIImageView! - + + @IBOutlet weak var button: UIButton! @IBAction func togglePlayerButtonWasTapped(_ sender: Any) { KDICPlayer.toggle() } + override func viewDidLoad() { super.viewDidLoad() + } + override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) print("About to play") - KDICPlayer.play() + KDICPlayer.live() print("Playing!") } + + } diff --git a/KDICCore/KDICPlayer.swift b/KDICCore/KDICPlayer.swift index 60adbe3..dc2b8b6 100644 --- a/KDICCore/KDICPlayer.swift +++ b/KDICCore/KDICPlayer.swift @@ -1,30 +1,38 @@ -import UIKit import AVFoundation private let streamURL = URL(string: "http://kdic.grinnell.edu/stream")! open class KDICPlayer { - private static var player: AVPlayer = { + static private(set) var isPlaying = false; + + private static var player: AVPlayer = freshPlayer() + + private class func freshPlayer() -> AVPlayer { let asset = AVURLAsset(url: streamURL) let playerItem = AVPlayerItem(asset: asset) return AVPlayer(playerItem: playerItem) - }() - - open static var isPlaying = player.rate != 0 + } - open class func play() { + open class func live() { + player = freshPlayer() + unpause() + } + + open class func unpause() { player.play() + isPlaying = true } open class func pause() { player.pause() + isPlaying = false } open class func toggle() { - if isPlaying { + if isPlaying == true { pause() } else { - play() + unpause() } }