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