예제 #1
0
        // Set up the table view cells
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell = TableView.DequeueReusableCell("cell");

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "cell");
            }

            if (loading)
            {
                cell.TextLabel.Text       = "Loading...";
                cell.DetailTextLabel.Text = "This may take a bit for a large library";
            }
            else
            {
                Song song = Songs.GetSongBySectionRow(indexPath.Section, indexPath.Row);
                cell.TextLabel.Text       = song.song;
                cell.TextLabel.Font       = UIFont.PreferredBody;
                cell.DetailTextLabel.Text = String.Format("Album: {0}", song.album);
                if (song == MyMusicPlayer.GetInstance().currentSong)
                {
                    cell.BackgroundColor = UIColor.FromRGB(0.9f, 0.9f, 0.9f);
                }
                else
                {
                    cell.BackgroundColor = UIColor.White;
                }
            }

            return(cell);
        }
예제 #2
0
 // Get ready to segue to the detail view controller
 public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
 {
     // The segue to use
     if (segue.Identifier == "showDetail")
     {
         detailViewController = segue.DestinationViewController as DetailViewController;
         if (sender == leftBBI)
         {
             Song song = Songs.GetStreamingSongByIndex(0);
             // Pass song info to the detail view controller
             detailViewController.song = song;
         }
         else if (sender == rightBBI)
         {
             Song playingSong = MyMusicPlayer.GetInstance().currentSong;
             detailViewController.song = playingSong;
         }
         else
         {
             // Selected song
             NSIndexPath indexPath = Songs.searching
                 ? searchController.SearchResultsTableView.IndexPathForSelectedRow
                 : TableView.IndexPathForSelectedRow;
             Song song = Songs.GetSongBySectionRow(indexPath.Section, indexPath.Row);
             song.streamingURL = null;
             // Pass song info to the detail view controller
             detailViewController.song = song;
         }
     }
 }
예제 #3
0
 public static MyMusicPlayer GetInstance()
 {
     if (MyMusicPlayer.myMusicPlayer == null)
     {
         MyMusicPlayer.myMusicPlayer = new MyMusicPlayer();
     }
     return(MyMusicPlayer.myMusicPlayer);
 }
예제 #4
0
        public void NowPlaying(UIBarButtonItem sender)
        {
            if (MyMusicPlayer.GetInstance().currentSong != null)
            {
                PerformSegue("showDetail", sender);
            }
            else
            {
                UIAlertController ac = UIAlertController.Create("No songs playing", "Please select a song to play",
                                                                UIAlertControllerStyle.Alert);
                UIAlertAction defaultAction = UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null);
                ac.AddAction(defaultAction);

                PresentViewController(ac, true, null);
            }
        }
예제 #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create and initialize music player
            musicPlayer               = MyMusicPlayer.GetInstance();
            musicPlayer.EndReached   -= MusicPlayer_PlayNextSong;
            musicPlayer.StartReached -= MusicPlayer_PlayPrevSong;
            musicPlayer.ReadyToPlay  -= MusicPlayer_EnablePlayPauseButton;
            musicPlayer.EndReached   += MusicPlayer_PlayNextSong;
            musicPlayer.StartReached += MusicPlayer_PlayPrevSong;
            musicPlayer.ReadyToPlay  += MusicPlayer_EnablePlayPauseButton;

            // set up handler for when app resumes from background
            NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("resumeFromBackground"),
                                                           UIApplication.DidBecomeActiveNotification, null);
            // Register for receiving controls from lock screen and controlscreen
            UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();
        }