Skip to content
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

Open
wants to merge 9 commits into
base: pheonix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 55 additions & 53 deletions KDIC/Base.lproj/Main_iPhone.storyboard

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions KDIC/Images.xcassets/Equalizer.imageset/Contents.json
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"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions KDIC/Images.xcassets/PauseButton.imageset/Contents.json
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"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions KDIC/Images.xcassets/PlayButton.imageset/Contents.json
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"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions KDIC/Launch Screen.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -13,9 +17,9 @@
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
43 changes: 42 additions & 1 deletion KDIC/PlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

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 for coin in the next line.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this. You can use the Aspect Fill setting I showed you on the storyboard to adjust how the image appears in the UIImage view.

{
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;
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Extraneous newline

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Extraneous newline.

}
9 changes: 6 additions & 3 deletions KDICCore/KDICPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@ import AVFoundation

private let streamURL = URL(string: "http://kdic.grinnell.edu/stream")!

private(set) var isPlaying = false;
Copy link
Member

Choose a reason for hiding this comment

The 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;
Copy link
Member

Choose a reason for hiding this comment

The 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must we use == here? Can't we just do if isPlaying?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have == true here? Please remove if it compiles without it. isPlaying is a Bool.

pause()
} else {
play()
Expand Down