mirror of
https://github.com/oonyeje/Get-Hip.git
synced 2025-12-25 19:57:42 +00:00
resized view controllers
This commit is contained in:
parent
994e033bfd
commit
b6378b35e7
@ -38,7 +38,7 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
|||||||
self.audioPlayer.volume = sender.value
|
self.audioPlayer.volume = sender.value
|
||||||
}
|
}
|
||||||
@IBAction func playPauseFav(sender: UIButton){
|
@IBAction func playPauseFav(sender: UIButton){
|
||||||
if (self.party.role == PeerType.Host_Creator){
|
if (self.party.role == PeerType.Host_Creator || self.party.role == PeerType.Guest_Creator){
|
||||||
if(playing == true){
|
if(playing == true){
|
||||||
for peer in self.party.session.connectedPeers {
|
for peer in self.party.session.connectedPeers {
|
||||||
var dictionary: [String: String] = ["sender": self.party.myPeerID.displayName, "instruction": "pause_stream"]
|
var dictionary: [String: String] = ["sender": self.party.myPeerID.displayName, "instruction": "pause_stream"]
|
||||||
@ -76,7 +76,7 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
|||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
self.progressBar.setProgress(0, animated: true)
|
self.progressBar.setProgress(0, animated: true)
|
||||||
|
|
||||||
if(self.party.role == PeerType.Host_Creator){
|
if(self.party.role == PeerType.Host_Creator || self.party.role == PeerType.Guest_Creator){
|
||||||
self.audioPlayer = AVPlayer(URL: self.party.currentSong.valueForProperty(MPMediaItemPropertyAssetURL) as! NSURL)
|
self.audioPlayer = AVPlayer(URL: self.party.currentSong.valueForProperty(MPMediaItemPropertyAssetURL) as! NSURL)
|
||||||
|
|
||||||
self.songImg.image = self.party.currentSong.valueForProperty(MPMediaItemPropertyArtwork).imageWithSize(songImg.frame.size)
|
self.songImg.image = self.party.currentSong.valueForProperty(MPMediaItemPropertyArtwork).imageWithSize(songImg.frame.size)
|
||||||
@ -90,7 +90,16 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
|||||||
}
|
}
|
||||||
self.audioPlayer.play()
|
self.audioPlayer.play()
|
||||||
self.timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("updateLabels"), userInfo: nil, repeats: true)
|
self.timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("updateLabels"), userInfo: nil, repeats: true)
|
||||||
}else if (self.party.role == PeerType.Guest_Invited){
|
|
||||||
|
//sets the next host of the party once the party starts
|
||||||
|
self.party.chooseNextHost()
|
||||||
|
print(self.party.currentHost)
|
||||||
|
|
||||||
|
//used to notify for end of song and initiate next host loop
|
||||||
|
|
||||||
|
//NSNotificationCenter.defaultCenter().addObserver(self, selector: "songDidEnd:", name: "AVPlayerItemDidPlayToEndTimeNotification", object: nil)
|
||||||
|
|
||||||
|
}else if (self.party.role == PeerType.Guest_Invited || self.party.role == PeerType.Host_Invited){
|
||||||
|
|
||||||
self.songImg.image = self.party.currentSongIMG
|
self.songImg.image = self.party.currentSongIMG
|
||||||
self.titleLabel.text = (self.party.currentSongTitle)
|
self.titleLabel.text = (self.party.currentSongTitle)
|
||||||
@ -102,21 +111,28 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//sets the next host of the party once the party starts
|
|
||||||
if(self.party.role == PeerType.Guest_Creator || self.party.role == PeerType.Host_Creator){
|
|
||||||
|
|
||||||
self.party.chooseNextHost()
|
|
||||||
print(self.party.currentHost)
|
|
||||||
NSNotificationCenter.defaultCenter().addObserver(self, selector: "songDidEnd:", name: "gotDisplayID", object: nil)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func songDidEnd(notification: NSNotification){
|
func songDidEnd(notification: NSNotification){
|
||||||
self.performSegueWithIdentifier("NextUpSegue", sender: nil)
|
if(self.party.role == PeerType.Host_Creator){
|
||||||
|
self.party.role == PeerType.Host_Invited
|
||||||
|
}else if (self.party.role == PeerType.Guest_Creator){
|
||||||
|
self.party.role == PeerType.Guest_Invited
|
||||||
|
}
|
||||||
|
|
||||||
|
for peer in self.party.connectedPeers() as! [MCPeerID]{
|
||||||
|
if (peer.displayName == self.party.currentHost){
|
||||||
|
var dictionary: [String: AnyObject] = ["sender": self.party.myPeerID, "instruction": "start_picking_a_song"]
|
||||||
|
self.party.sendInstruction(dictionary, toPeer: peer)
|
||||||
|
}else{
|
||||||
|
var dictionary: [String: AnyObject] = ["sender": self.party.myPeerID, "instruction": "wait_in_nextUp_Scene"]
|
||||||
|
self.party.sendInstruction(dictionary, toPeer: peer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.performSegueWithIdentifier("NextUpSegue", sender: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func timeFormat(value: Float) -> String{
|
func timeFormat(value: Float) -> String{
|
||||||
@ -195,6 +211,18 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
|
|||||||
if segue.identifier == "NextUpSegue" {
|
if segue.identifier == "NextUpSegue" {
|
||||||
let vc: NextUpViewController = (segue.destinationViewController as? NextUpViewController)!
|
let vc: NextUpViewController = (segue.destinationViewController as? NextUpViewController)!
|
||||||
vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData)
|
vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if segue.identifier == "NextSongSelectionSegue" {
|
||||||
|
|
||||||
|
let vc: SongSelectionViewController = (segue.destinationViewController as? SongSelectionViewController)!
|
||||||
|
vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +266,7 @@ extension CurrentlyPlayingViewController: PartyServiceManagerDelegate {
|
|||||||
|
|
||||||
}else if(instruction == "want_to_be_host"){
|
}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)
|
let alert = UIAlertController(title: "Hosting 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:{
|
alert.addAction(UIAlertAction(title: "Accept", style: .Default, handler:{
|
||||||
(action: UIAlertAction!) -> Void in
|
(action: UIAlertAction!) -> Void in
|
||||||
|
|
||||||
@ -255,6 +283,17 @@ extension CurrentlyPlayingViewController: PartyServiceManagerDelegate {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
self.presentViewController(alert, animated: true, completion: nil)
|
self.presentViewController(alert, animated: true, completion: nil)
|
||||||
|
|
||||||
|
}else if(instruction == "start_picking_a_song"){
|
||||||
|
if(self.party.role == PeerType.Host_Invited){
|
||||||
|
self.party.role == PeerType.Host_Creator
|
||||||
|
}
|
||||||
|
if(self.party.role == PeerType.Guest_Invited){
|
||||||
|
self.party.role == PeerType.Guest_Creator
|
||||||
|
}
|
||||||
|
self.performSegueWithIdentifier("NextSongSelectionSegue", sender: self)
|
||||||
|
}else if(instruction == "wait_in_nextUp_Scene"){
|
||||||
|
self.performSegueWithIdentifier("NextUpSegue", sender: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -7,8 +7,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import MultipeerConnectivity
|
||||||
|
|
||||||
class NextUpViewController: UIViewController {
|
class NextUpViewController: UIViewController, PartyServiceManagerDelegate {
|
||||||
var party: PartyServiceManager!
|
var party: PartyServiceManager!
|
||||||
var usr: [UserParseData] = []
|
var usr: [UserParseData] = []
|
||||||
var frnds: [FriendData] = []
|
var frnds: [FriendData] = []
|
||||||
@ -17,6 +18,7 @@ class NextUpViewController: UIViewController {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
self.party.delegate = self
|
||||||
self.userImages.layer.cornerRadius = self.userImages.frame.size.width/2
|
self.userImages.layer.cornerRadius = self.userImages.frame.size.width/2
|
||||||
self.userImages.clipsToBounds = true
|
self.userImages.clipsToBounds = true
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
@ -35,14 +37,55 @@ class NextUpViewController: UIViewController {
|
|||||||
self.requestData = request
|
self.requestData = request
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// MARK: - Navigation
|
// MARK: - Navigation
|
||||||
|
|
||||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
||||||
// Get the new view controller using segue.destinationViewController.
|
// Get the new view controller using segue.destinationViewController.
|
||||||
// Pass the selected object to the new view controller.
|
// Pass the selected object to the new view controller.
|
||||||
|
|
||||||
|
if(segue.identifier == "NextSongSegue"){
|
||||||
|
let vc: CurrentlyPlayingViewController = (segue.destinationViewController as? CurrentlyPlayingViewController)!
|
||||||
|
|
||||||
|
vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension NextUpViewController: PartyServiceManagerDelegate {
|
||||||
|
|
||||||
|
func foundPeer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func lostPeer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func invitationWasRecieved(peerID: MCPeerID, invitationHandler: ((Bool, MCSession!) -> Void)!) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func connectedWithPeer(peerID: MCPeerID) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func didRecieveInstruction(dictionary: Dictionary<String, AnyObject>){
|
||||||
|
let (instruction, fromPeer) = self.party.decodeInstruction(dictionary)
|
||||||
|
|
||||||
|
if self.party.disconnectedPeersDictionary[fromPeer.displayName] != nil {
|
||||||
|
|
||||||
|
var dictionary: [String: String] = ["sender": self.party.myPeerID.displayName, "instruction": "disconnect"]
|
||||||
|
self.party.sendInstruction(dictionary, toPeer: fromPeer)
|
||||||
|
}else{
|
||||||
|
if (instruction == "start"){
|
||||||
|
self.performSegueWithIdentifier("NextSongSegue", sender: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import MediaPlayer
|
import MediaPlayer
|
||||||
|
import MultipeerConnectivity
|
||||||
|
|
||||||
class SongSelectionViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
class SongSelectionViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
||||||
var party: PartyServiceManager!
|
var party: PartyServiceManager!
|
||||||
@ -167,7 +168,12 @@ class SongSelectionViewController: UIViewController, UITableViewDelegate, UITabl
|
|||||||
var songs = songsQuery.items
|
var songs = songsQuery.items
|
||||||
var rowItem: MPMediaItem = songs[indexPath.row - 1] as! MPMediaItem
|
var rowItem: MPMediaItem = songs[indexPath.row - 1] as! MPMediaItem
|
||||||
self.party.setSong(rowItem)
|
self.party.setSong(rowItem)
|
||||||
self.performSegueWithIdentifier("LoadingPartySegue", sender: nil)
|
if(self.party.role == PeerType.Host_Creator){
|
||||||
|
self.performSegueWithIdentifier("LoadingPartySegue", sender: self)
|
||||||
|
}else{
|
||||||
|
self.performSegueWithIdentifier("NextSongCurrentlyPlayingSegue", sender: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,6 +293,35 @@ class SongSelectionViewController: UIViewController, UITableViewDelegate, UITabl
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(segue.identifier == "NextSongCurrentlyPlayingSegue"){
|
||||||
|
|
||||||
|
let vc: CurrentlyPlayingViewController = (segue.destinationViewController as? CurrentlyPlayingViewController)!
|
||||||
|
vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData)
|
||||||
|
|
||||||
|
//sends music info incuding, title, artist, album, and image
|
||||||
|
var dictionary: [String: AnyObject] = ["sender": self.party.myPeerID.displayName, "instruction": "set_up_song", "songTitle": (self.party.currentSong.valueForProperty(MPMediaItemPropertyTitle) as? String!)!, "songArtistAndAlbum": (self.party.currentSong.valueForProperty(MPMediaItemPropertyArtist) as? String!)! + " - " + (self.party.currentSong.valueForProperty(MPMediaItemPropertyAlbumTitle) as? String!)!, "songImage": UIImagePNGRepresentation(self.party.currentSong.valueForProperty(MPMediaItemPropertyArtwork).imageWithSize(CGSize(width: 320, height: 320)) )]
|
||||||
|
|
||||||
|
|
||||||
|
for peer in self.party.connectedPeers() as! [MCPeerID] {
|
||||||
|
self.party.sendInstruction(dictionary, toPeer: peer)
|
||||||
|
|
||||||
|
//open stream with peer
|
||||||
|
let stream = self.party.outputStreamForPeer(peer)
|
||||||
|
self.party.outputStreamers[peer.displayName] = TDAudioOutputStreamer(outputStream: stream)
|
||||||
|
self.party.outputStreamers[peer.displayName]!.streamAudioFromURL((self.party.currentSong.valueForProperty(MPMediaItemPropertyAssetURL) as! NSURL))
|
||||||
|
}
|
||||||
|
|
||||||
|
dictionary = ["sender": self.party.myPeerID.displayName, "instruction": "start"]
|
||||||
|
|
||||||
|
for peer in self.party.connectedPeers() as! [MCPeerID] {
|
||||||
|
self.party.sendInstruction(dictionary, toPeer: peer)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user