-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amanda/ui features #30
base: pheonix
Are you sure you want to change the base?
Changes from 7 commits
925f3b8
9558056
07287bd
211aa44
559eea6
58e0dae
92ce5b3
b7c5931
8741444
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,58 @@ class PlayerViewController: UIViewController { | |
@IBOutlet weak var titleLabel: UILabel! | ||
@IBOutlet weak var subtitleLabel: UILabel! | ||
@IBOutlet weak var imageView: UIImageView! | ||
|
||
@IBAction func togglePlayerButtonWasTapped(_ sender: Any) { | ||
KDICPlayer.toggle() | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.imageView.image = UIImage(named: "Equalizer") | ||
|
||
button.setImage(imgShell1, forState:.Normal); | ||
button.setImage(coin, forState:.Highlighted); | ||
|
||
button.setBackgroundImage(resizeImageWithAspect(UIImage(data: data!)!,size:button.bounds.size), forState: .Normal); | ||
button.contentMode = UIViewContentMode.ScaleAspectFit; | ||
button.clipsToBounds = true; | ||
|
||
} | ||
|
||
override func viewDidAppear(_ animated: Bool) { | ||
super.viewDidAppear(animated) | ||
print("About to play") | ||
KDICPlayer.play() | ||
print("Playing!") | ||
} | ||
|
||
func resizeImageWithAspect(image: UIImage,size: CGSize)->UIImage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need this. You can use the |
||
{ | ||
let oldWidth = image.size.width; | ||
let oldHeight = image.size.height; | ||
|
||
let scaleFactor = (oldWidth > oldHeight) ? size.width / oldWidth : size.height / oldHeight; | ||
|
||
let newHeight = oldHeight * scaleFactor; | ||
let newWidth = oldWidth * scaleFactor; | ||
let newSize = CGSizeMake(newWidth, newHeight); | ||
|
||
if UIScreen.mainScreen().respondsToSelector(#selector(NSDecimalNumberBehaviors.scale)){ | ||
UIGraphicsBeginImageContextWithOptions(newSize,false,UIScreen.mainScreen().scale); | ||
} | ||
else | ||
{ | ||
UIGraphicsBeginImageContext(newSize); | ||
} | ||
|
||
image.drawInRect(CGRectMake(0, 0, newSize.width, size.height)); | ||
let newImage = UIGraphicsGetImageFromCurrentImageContext(); | ||
UIGraphicsEndImageContext(); | ||
|
||
return newImage; | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Extraneous newline There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Extraneous newline. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,28 @@ import AVFoundation | |
|
||
private let streamURL = URL(string: "http://kdic.grinnell.edu/stream")! | ||
|
||
private(set) var isPlaying = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be in the class, like on line 9. |
||
|
||
open class KDICPlayer { | ||
private static var player: AVPlayer = { | ||
let asset = AVURLAsset(url: streamURL) | ||
let playerItem = AVPlayerItem(asset: asset) | ||
let currentlyPlaying = isPlaying; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You never use this binding. |
||
return AVPlayer(playerItem: playerItem) | ||
}() | ||
|
||
open static var isPlaying = player.rate != 0 | ||
|
||
open class func play() { | ||
player.play() | ||
isPlaying = true | ||
} | ||
|
||
open class func pause() { | ||
player.pause() | ||
isPlaying = false | ||
} | ||
|
||
open class func toggle() { | ||
if isPlaying { | ||
if isPlaying == true { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to have |
||
pause() | ||
} else { | ||
play() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? Where is
imgShell1
coming from? Same forcoin
in the next line.