Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
final submission!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwal committed Nov 19, 2016
1 parent da59487 commit 1d8d6ef
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Play/Play.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
3AA8F0031C097DB8005ACCBD = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 0800;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -284,6 +285,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Play/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "cs198-1.Play";
Expand All @@ -296,6 +298,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Play/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "cs198-1.Play";
Expand Down
10 changes: 10 additions & 0 deletions Play/Play/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down
10 changes: 5 additions & 5 deletions Play/Play/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9060" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -14,10 +15,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"/>
<animations/>
<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
66 changes: 62 additions & 4 deletions Play/Play/PlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// PlayerViewController.swift
// Play
//
// Created by Gene Yoo on 11/26/15.
// Copyright © 2015 cs198-1. All rights reserved.
// Created by Alex Walczak.
//

import UIKit
Expand All @@ -25,6 +24,8 @@ class PlayerViewController: UIViewController {
var artistLabel: UILabel!
var titleLabel: UILabel!
var didPlay: [Track]!

var currentTime: CMTime!

var paused = true

Expand Down Expand Up @@ -135,7 +136,23 @@ class PlayerViewController: UIViewController {
let track = tracks[currentIndex]
let url = URL(string: "https://api.soundcloud.com/tracks/\(track.id as Int)/stream?client_id=\(clientID)")!
// FILL ME IN

if (sender.isSelected) {
player.pause()
paused = true
currentTime = player.currentTime()
sender.isSelected = false
} else {
let playerItem = AVPlayerItem(url:url)
if (player.items().count == 0) {
player = AVQueuePlayer(playerItem: playerItem)
} else {
player.seek(to: currentTime)
}
player.rate = 1.0;
player.play()
paused = false
sender.isSelected = true
}
}

/*
Expand All @@ -146,6 +163,20 @@ class PlayerViewController: UIViewController {
*/
func nextTrackTapped(_ sender: UIButton) {
// FILL ME IN
currentIndex = currentIndex + 1
loadTrackElements()
let tzero : CMTime = CMTimeMake(0, 1)
currentTime = tzero
let path = Bundle.main.path(forResource: "Info", ofType: "plist")
let clientID = NSDictionary(contentsOfFile: path!)?.value(forKey: "client_id") as! String
let track = tracks[currentIndex]
let url = URL(string: "https://api.soundcloud.com/tracks/\(track.id as Int)/stream?client_id=\(clientID)")!
let playerItem = AVPlayerItem(url:url)
player = AVQueuePlayer(playerItem: playerItem)
if (playPauseButton.isSelected) {
player.rate = 1.0;
player.play()
}
}

/*
Expand All @@ -160,6 +191,34 @@ class PlayerViewController: UIViewController {

func previousTrackTapped(_ sender: UIButton) {
// FILL ME IN
currentTime = player.currentTime()
let seconds : Int64 = 0
let preferredTimeScale : Int32 = 1
let tzero : CMTime = CMTimeMake(seconds, preferredTimeScale)
// Part A
if currentTime.seconds > 3 {
if (player.items().count > 0) {
player.seek(to: tzero)
currentTime = tzero
}
} else {
// Part B
if currentIndex > 0 {
currentIndex = currentIndex - 1
loadTrackElements()
currentTime = tzero
let path = Bundle.main.path(forResource: "Info", ofType: "plist")
let clientID = NSDictionary(contentsOfFile: path!)?.value(forKey: "client_id") as! String
let track = tracks[currentIndex]
let url = URL(string: "https://api.soundcloud.com/tracks/\(track.id as Int)/stream?client_id=\(clientID)")!
let playerItem = AVPlayerItem(url:url)
player = AVQueuePlayer(playerItem: playerItem)
if (playPauseButton.isSelected) {
player.rate = 1.0;
player.play()
}
}
}
}


Expand All @@ -185,4 +244,3 @@ class PlayerViewController: UIViewController {
loadTrackElements()
}
}

0 comments on commit 1d8d6ef

Please sign in to comment.