diff --git a/GetHip.xcodeproj/project.pbxproj b/GetHip.xcodeproj/project.pbxproj index 5655350..91f2419 100644 --- a/GetHip.xcodeproj/project.pbxproj +++ b/GetHip.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ 3E4169491C385F1000B193AF /* 1x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E4169481C385F1000B193AF /* 1x.png */; }; 3E4169551C398A5B00B193AF /* SignUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4169541C398A5B00B193AF /* SignUpViewController.swift */; }; 3E4169571C399C4D00B193AF /* Images-3.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3E4169561C399C4D00B193AF /* Images-3.xcassets */; }; + 3E416EEE1C97BE31001EA319 /* NextUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E416EED1C97BE31001EA319 /* NextUpViewController.swift */; }; 3E41D74C1C8D17E100FFD846 /* icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E41D74B1C8D17E100FFD846 /* icon-120.png */; }; 3E41D74E1C8D17F300FFD846 /* Icon-60.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E41D74D1C8D17F300FFD846 /* Icon-60.png */; }; 3E438ADE1C572DFD0055C97A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3E438ADD1C572DFD0055C97A /* Main.storyboard */; }; @@ -197,6 +198,7 @@ 3E4169481C385F1000B193AF /* 1x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = 1x.png; path = "../../../Dropbox/Gethip/Screens/Logo Screen/6 Logo Screen/1x.png"; sourceTree = ""; }; 3E4169541C398A5B00B193AF /* SignUpViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpViewController.swift; sourceTree = ""; }; 3E4169561C399C4D00B193AF /* Images-3.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Images-3.xcassets"; sourceTree = ""; }; + 3E416EED1C97BE31001EA319 /* NextUpViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NextUpViewController.swift; sourceTree = ""; }; 3E41D74B1C8D17E100FFD846 /* icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-120.png"; sourceTree = ""; }; 3E41D74D1C8D17F300FFD846 /* Icon-60.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-60.png"; sourceTree = ""; }; 3E438ADD1C572DFD0055C97A /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; @@ -368,6 +370,7 @@ 3E101F041C52E50400C895CA /* PartySessionSource */ = { isa = PBXGroup; children = ( + 3E416EEC1C97BDEA001EA319 /* NextUpInParty */, 3E6D43871C78318F00CA805F /* InvitedToParty */, 3E1EE6371C6D029800F5C5D7 /* InParty */, 3E34125A1C54C73A006226E0 /* PartySession.swift */, @@ -492,6 +495,14 @@ name = SelectSong; sourceTree = ""; }; + 3E416EEC1C97BDEA001EA319 /* NextUpInParty */ = { + isa = PBXGroup; + children = ( + 3E416EED1C97BE31001EA319 /* NextUpViewController.swift */, + ); + name = NextUpInParty; + sourceTree = ""; + }; 3E438AE01C57387B0055C97A /* iPhone5 */ = { isa = PBXGroup; children = ( @@ -943,6 +954,7 @@ 3E627FE71C55AE35005C0372 /* NSMutableArray+QueueMethods.m in Sources */, 3E3B14DE1C5BCC9B001C437F /* FriendRequestViewController.swift in Sources */, 3E18D4931C51F6230012F7DF /* UserParseData.swift in Sources */, + 3E416EEE1C97BE31001EA319 /* NextUpViewController.swift in Sources */, 3E5952851C39E54A00C88C71 /* HomeScreenViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/GetHip/CurrentlyPlayingViewController.swift b/GetHip/CurrentlyPlayingViewController.swift index 5c836d9..38108a7 100644 --- a/GetHip/CurrentlyPlayingViewController.swift +++ b/GetHip/CurrentlyPlayingViewController.swift @@ -107,6 +107,7 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg self.party.chooseNextHost() print(self.party.currentHost) + NSNotificationCenter.defaultCenter().addObserver(self, selector: "songDidEnd:", name: "gotDisplayID", object: nil) } @@ -114,6 +115,10 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg } + func songDidEnd(notification: NSNotification){ + self.performSegueWithIdentifier("NextUpSegue", sender: nil) + } + func timeFormat(value: Float) -> String{ var minutes: Float = floor(roundf((value)/60)) println(minutes) @@ -186,6 +191,11 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg let vc: BackToHomeScreenViewController = (segue.destinationViewController as? BackToHomeScreenViewController)! vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData) } + + if segue.identifier == "NextUpSegue" { + let vc: NextUpViewController = (segue.destinationViewController as? NextUpViewController)! + vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData) + } } @@ -219,9 +229,32 @@ extension CurrentlyPlayingViewController: PartyServiceManagerDelegate { self.party.sendInstruction(dictionary, toPeer: fromPeer) }else{ if(instruction == "pause_stream"){ + self.party.inputStreamer.pause() + }else if(instruction == "resume_stream"){ + self.party.inputStreamer.resume() + + }else if(instruction == "want_to_be_host"){ + + let alert = UIAlertController(title: "Host Request", message: "Would you like to be the next host for the party and pick a song?", preferredStyle: .Alert) + alert.addAction(UIAlertAction(title: "Accept", style: .Default, handler:{ + (action: UIAlertAction!) -> Void in + + self.party.currentHost = self.party.myPeerID.displayName + alert.dismissViewControllerAnimated(true, completion: nil) + + })) + + alert.addAction(UIAlertAction(title: "Decline", style: .Default, handler:{ + (action: UIAlertAction!) -> Void in + var dictionary: [String: AnyObject] = ["sender": self.party.myPeerID, "instruction": "does_not_accept"] + self.party.sendInstruction(dictionary, toPeer: fromPeer) + alert.dismissViewControllerAnimated(true, completion: nil) + })) + + self.presentViewController(alert, animated: true, completion: nil) } } diff --git a/GetHip/Main.storyboard b/GetHip/Main.storyboard index a8a3fb1..257d9c4 100644 --- a/GetHip/Main.storyboard +++ b/GetHip/Main.storyboard @@ -192,6 +192,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1327,6 +1366,7 @@ + @@ -1590,9 +1630,6 @@ - - - + + + diff --git a/GetHip/NextUpViewController.swift b/GetHip/NextUpViewController.swift new file mode 100644 index 0000000..333d891 --- /dev/null +++ b/GetHip/NextUpViewController.swift @@ -0,0 +1,48 @@ +// +// NextUpViewController.swift +// GetHip +// +// Created by Okechi on 3/14/16. +// Copyright (c) 2016 Kroleo. All rights reserved. +// + +import UIKit + +class NextUpViewController: UIViewController { + var party: PartyServiceManager! + var usr: [UserParseData] = [] + var frnds: [FriendData] = [] + var requestData: [FriendData] = [] + @IBOutlet weak var userImages: UIImageView! + + override func viewDidLoad() { + super.viewDidLoad() + self.userImages.layer.cornerRadius = self.userImages.frame.size.width/2 + self.userImages.clipsToBounds = true + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + func setData(prty:PartyServiceManager, user: [UserParseData], friends: [FriendData], request: [FriendData]){ + self.party = prty + self.usr = user + self.frnds = friends + self.requestData = request + } + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/GetHip/PartyServiceManager.swift b/GetHip/PartyServiceManager.swift index 5b9f4b8..506d90d 100644 --- a/GetHip/PartyServiceManager.swift +++ b/GetHip/PartyServiceManager.swift @@ -93,6 +93,8 @@ class PartyServiceManager: NSObject, AnyObject { chooseNextHost() }else{ self.currentHost = self.connectedPeers()[nextHostIndex].displayName + var dictionary: [String: AnyObject] = ["sender": self.myPeerID, "instruction": "want_to_be_host"] + self.sendInstruction(dictionary, toPeer: self.connectedPeersDictionary[self.currentHost] as! MCPeerID) } } @@ -174,8 +176,15 @@ class PartyServiceManager: NSObject, AnyObject { } } + if(instruction == "does_not_accept"){ + self.chooseNextHost() + } + + + return (instruction!, fromPeer) - }else{ + } + else{ return ("not_an_instruction", fromPeer) }