Exemple #1
0
		public async override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.CatalogBrowser.TracksQueued += async (sender, tracks) => {
				try {
					await playQueue.PlayAsync (tracks);
				} catch (OperationCanceledException) {
					// This is ok, let's ignore it!
				} catch (Exception ex) {
					LoggingService.LogError (ex, "An unhandled exception happened playing a song");
				}
			};

			var serverDetails = Caches.LoadKnownServers ().FirstOrDefault (t => t.Default);
			var server = new TunezServer (serverDetails);
			var catalog = await server.FetchCatalog (Path.Combine (CacheDirectory, "tunez.catalog"), System.Threading.CancellationToken.None);

			var playPauseItem = (NSToolbarItem) NSApplication.SharedApplication.Windows[0].Toolbar.Items[0];
			var playPauseButton = (NSButton) NSApplication.SharedApplication.Windows[0].Toolbar.Items[0].View;
			var progress = NSApplication.SharedApplication.Windows[0].Toolbar.Items[1];
			var label = (NSTextField)NSApplication.SharedApplication.Windows[0].Toolbar.Items[2].View;
			var monitors = new TrackMonitorGroup {
				new PlayingProgressMonitor (progress, label),
			};
			if (!string.IsNullOrEmpty (LastFMAppCredentials.APIKey))
				monitors.Add (new ScrobblingMonitor (new Scrobbler (Caches.Scrobbler)));

			playQueue = new PlayQueue<MacStreamingPlayer> (server, new NullNetworkChangedListener (), monitors);

			PlayPauseButton (playPauseItem, playPauseButton);
			PopulateBrowser (catalog);
			LoggingService.LogInfo ("Initialization complete...");
		}
Exemple #2
0
		public override void ViewDidLoad()
		{
			var menuController = StoryboardHelper.Main.CreateNavigationMenuController ();
			ContentViewController = new ContentViewController ();
			SidebarController = new SidebarNavigation.SidebarController (this, ContentViewController, menuController) {
				MenuLocation = SidebarNavigation.MenuLocations.Left
			};

			NowPlayingStatusView = NowPlayingStatusView.Create ();

			Monitors = new TrackMonitorGroup {
				new NowPlayingMonitor (View, SidebarController.View, NowPlayingStatusView),
			};
			if (!string.IsNullOrEmpty (LastFMAppCredentials.APIKey)) {
				Scrobbler = new Scrobbler (Caches.Scrobbler);
				Monitors.Add (new ScrobblingMonitor (Scrobbler));
			}

			NowPlayingStatusView.PlayPausePressed += (o, e) => CatalogController.PlayQueue.IsPaused = !CatalogController.PlayQueue.IsPaused;
			menuController.CatalogSelected += (o, e) => {
				SidebarController.CloseMenu (true);
				ContentViewController.Content = CatalogController;
			};
			if (Scrobbler == null) {
				menuController.LastFMSupported = false;
			} else {
				menuController.LastFMSupported = true;
				menuController.LastFmSelected += (o, e) => {
					SidebarController.CloseMenu (true);
					ContentViewController.Content = StoryboardHelper.Main.CreateLastFMLoginController (Scrobbler);
				};
			}
			menuController.SelectServerSelected += (o, e) => {
				SidebarController.CloseMenu (true);
				ChangeServerAsync ();
			};

			MonitorAudioRouteChangedAsync ();

			var server = Caches.LoadKnownServers ().FirstOrDefault (t => t.Default);
			if (server != null)
				ConnectToServer (server);
			else
				ChangeServerAsync ();
		}