From 4bc10d3a80ccdf5ce17fdc3cf4a9ab68e3913ff3 Mon Sep 17 00:00:00 2001 From: Okechi Date: Fri, 29 Jan 2016 02:14:15 -0500 Subject: [PATCH] prototype for loading party screen done --- GetHip/Main.storyboard | 99 ++++++++++++++++++++++++ GetHip/PartyServiceManager.swift | 8 ++ GetHip/SongSelectionViewController.swift | 43 +++++++++- 3 files changed, 149 insertions(+), 1 deletion(-) diff --git a/GetHip/Main.storyboard b/GetHip/Main.storyboard index 2c04097..3841ee1 100644 --- a/GetHip/Main.storyboard +++ b/GetHip/Main.storyboard @@ -488,6 +488,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -608,6 +704,9 @@ + + + diff --git a/GetHip/PartyServiceManager.swift b/GetHip/PartyServiceManager.swift index 9e2dd18..50b3352 100644 --- a/GetHip/PartyServiceManager.swift +++ b/GetHip/PartyServiceManager.swift @@ -8,6 +8,7 @@ import Foundation import MultipeerConnectivity +import MediaPlayer protocol PartyServiceManagerDelegate { @@ -47,6 +48,9 @@ class PartyServiceManager: NSObject { var connectingPeersDictionary = NSMutableDictionary() var disconnectedPeersDictionary = NSMutableDictionary() + //party variables + var currentSong: MPMediaItem! = nil + /*init(){ //self.serviceAdvertiser = MCNearbyServiceAdvertiser(peer: self.myPeerID, discoveryInfo: nil, serviceType: self.PartyServiceType) @@ -132,6 +136,10 @@ class PartyServiceManager: NSObject { println("Started Browsing for peers") } + func setSong(media: MPMediaItem!){ + self.currentSong = media + } + //Deprecated /* func setData(dispName: String){ diff --git a/GetHip/SongSelectionViewController.swift b/GetHip/SongSelectionViewController.swift index d02a856..3750c43 100644 --- a/GetHip/SongSelectionViewController.swift +++ b/GetHip/SongSelectionViewController.swift @@ -10,7 +10,7 @@ import UIKit import MediaPlayer class SongSelectionViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { - + var party: PartyServiceManager! = nil @IBOutlet weak var table: UITableView! @@ -118,6 +118,47 @@ class SongSelectionViewController: UIViewController, UITableViewDelegate, UITabl } func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + + if( indexPath.row == 0){ + + + } + else{ + switch self.filter{ + + //return albums cell + case "albums": + let cell = self.table.dequeueReusableCellWithIdentifier("AlbumCell", forIndexPath: indexPath) as? AlbumCell + + + var albumsQuery = MPMediaQuery.albumsQuery() + var albums = albumsQuery.items + var rowItem: MPMediaItem = albums[indexPath.row - 1] as! MPMediaItem + //segue to song selection from album selection + + + //return artists cell + case "artists": + let cell = self.table.dequeueReusableCellWithIdentifier("ArtistCell", forIndexPath: indexPath) as? ArtistCell + + + var artistsQuery = MPMediaQuery.artistsQuery() + var artists = artistsQuery.items + var rowItem: MPMediaItem = artists[indexPath.row - 1] as! MPMediaItem + //segue to song selction from artist + + //return song cell + default: + let cell = self.table.dequeueReusableCellWithIdentifier("SongCell", forIndexPath: indexPath) as? SongCell + + + var songsQuery = MPMediaQuery.songsQuery() + var songs = songsQuery.items + var rowItem: MPMediaItem = songs[indexPath.row - 1] as! MPMediaItem + self.party.setSong(rowItem) + } + } + } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {