mirror of
https://github.com/oonyeje/Get-Hip.git
synced 2025-12-25 03:37:40 +00:00
working on repeating the songs
This commit is contained in:
parent
3cca20f639
commit
d7eec3168c
@ -23,6 +23,7 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
||||
var nextHost: String!
|
||||
var messageOutputStream: Dictionary<String, NSOutputStream>!
|
||||
var messageInputStream: Dictionary<String, NSInputStream>!
|
||||
var firstPass = true
|
||||
@IBOutlet var segmentControl: UISegmentedControl!
|
||||
|
||||
//class variable for responding to peer who has just sent a message
|
||||
@ -149,6 +150,7 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
@ -247,9 +249,16 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
||||
override func viewDidAppear(animated: Bool) {
|
||||
//make this part check which view to display later
|
||||
|
||||
if(self.firstPass){
|
||||
self.firstPass = !self.firstPass
|
||||
}else{
|
||||
viewDidLoad()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func songDidEnd(notification: NSNotification){
|
||||
|
||||
if(self.party.role == PeerType.Host_Creator){
|
||||
self.party.role == PeerType.Host_Invited
|
||||
}else if (self.party.role == PeerType.Guest_Creator){
|
||||
@ -258,6 +267,8 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
||||
|
||||
var didAnyoneBecomeHost: Bool = false
|
||||
for peer in self.party.connectedPeers() as! [MCPeerID]{
|
||||
self.party.outputStreamers[peer.displayName]?.stop()
|
||||
|
||||
if ((self.party.currentHost != nil) && (peer.displayName == self.party.currentHost)){
|
||||
var dictionary: [String: AnyObject] = ["sender": self.party.myPeerID, "instruction": "start_picking_a_song"]
|
||||
self.party.sendInstruction(dictionary, toPeer: peer)
|
||||
@ -269,9 +280,9 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
||||
}
|
||||
|
||||
if(didAnyoneBecomeHost){
|
||||
self.performSegueWithIdentifier("NextSongSelectionSegue", sender: self)
|
||||
}else{
|
||||
self.performSegueWithIdentifier("NextUpSegue", sender: self)
|
||||
}else{
|
||||
self.performSegueWithIdentifier("NextSongSelectionSegue", sender: self)
|
||||
}
|
||||
|
||||
}
|
||||
@ -379,8 +390,8 @@ extension CurrentlyPlayingViewController {
|
||||
if(indexPath.row == 0){
|
||||
cell.friendImage.image = self.usr[0].profileImg.image!
|
||||
}
|
||||
else if((indexPath.row > 0) && (indexPath.row < self.party.invitedFriends.count)){
|
||||
let friend = self.party.invitedFriends[indexPath.row]
|
||||
else if((indexPath.row > 0) && (indexPath.row <= self.party.invitedFriends.count)){
|
||||
let friend = self.party.invitedFriends[indexPath.row - 1]
|
||||
if friend.profileImg == nil {
|
||||
cell.friendImage.backgroundColor = UIColor.lightGrayColor()
|
||||
}
|
||||
@ -466,6 +477,7 @@ extension CurrentlyPlayingViewController: PartyServiceManagerDelegate {
|
||||
self.party.inputStreamer.resume()
|
||||
|
||||
}else if(instruction == "want_to_be_host"){
|
||||
self.curr_fromPeer = fromPeer
|
||||
|
||||
let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
|
||||
dispatch_async(dispatch_get_global_queue(priority, 0)) {
|
||||
@ -497,6 +509,7 @@ extension CurrentlyPlayingViewController: PartyServiceManagerDelegate {
|
||||
|
||||
}else{
|
||||
let alert = UIAlertView()
|
||||
alert.delegate = self
|
||||
|
||||
alert.title = "Hosting Rrequest"
|
||||
alert.message = "Would you like to be the next host for the party and pick a song?"
|
||||
|
||||
@ -192,10 +192,15 @@ class LoadingPartyViewController: UIViewController, UICollectionViewDataSource,
|
||||
cell.friendImage.clipsToBounds = true
|
||||
|
||||
if(self.party.connectedPeersDictionary[friend.displayName] == nil){
|
||||
dispatch_async(dispatch_get_main_queue()){
|
||||
cell.alpha = 0.5
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return cell
|
||||
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ extension NextUpViewController: PartyServiceManagerDelegate {
|
||||
var dictionary: [String: String] = ["sender": self.party.myPeerID.displayName, "instruction": "disconnect"]
|
||||
self.party.sendInstruction(dictionary, toPeer: fromPeer)
|
||||
}else{
|
||||
if (instruction == "start"){
|
||||
if (instruction == "start_party"){
|
||||
self.performSegueWithIdentifier("NextSongSegue", sender: self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ class PartyServiceManager: NSObject, AnyObject {
|
||||
|
||||
if(instruction == "does_accept"){
|
||||
|
||||
self.currentHost == fromPeer.displayName
|
||||
self.currentHost = fromPeer.displayName
|
||||
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ extension PartyServiceManager: MCSessionDelegate{
|
||||
NSLog("%@", "peer \(peerID) didChangeState: \(state.stringValue())")
|
||||
self.disconnectedPeersDictionary[peerID.displayName] = peerID
|
||||
if self.connectedPeersDictionary[peerID.displayName] != nil{
|
||||
// self.connectedPeersDictionary[peerID.displayName] = nil
|
||||
self.connectedPeersDictionary[peerID.displayName] = MCPeerID(displayName: "@nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ class SongSelectionViewController: UIViewController, UITableViewDelegate, UITabl
|
||||
|
||||
for i_peer in self.party.invitedFriends{
|
||||
for peer in self.party.foundPeers {
|
||||
if (peer.displayName == i_peer.displayName && self.party.myPeerID.hash > peer.hash){
|
||||
if (peer.displayName == i_peer.displayName /*&& self.party.myPeerID.hash > peer.hash*/ && (self.party.connectedPeersDictionary[peer.displayName] == nil || self.party.connectedPeersDictionary[peer.displayName]!.displayName == "@nil" )){
|
||||
self.party.serviceBrowser.invitePeer(peer, toSession: self.party.session, withContext: nil, timeout: 30.0)
|
||||
|
||||
break
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user