public void RefreshCloudDeviceInfo(CloudDeviceInfo info, AudioFile audioFile) { Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { lblDeviceName.Content = info.DeviceName; lblArtistName.Content = audioFile.ArtistName; lblAlbumTitle.Content = audioFile.AlbumTitle; lblSongTitle.Content = audioFile.Title; lblLastUpdated.Content = string.Format("Last updated: {0}", info.Timestamp); imageAlbum.Source = null; var task = Task<BitmapImage>.Factory.StartNew(() => { try { var bytes = AudioFile.ExtractImageByteArrayForAudioFile(audioFile.FilePath); var stream = new MemoryStream(bytes); stream.Seek(0, SeekOrigin.Begin); var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = stream; bitmap.EndInit(); bitmap.Freeze(); return bitmap; } catch (Exception ex) { Console.WriteLine("An error occured while extracing album art in {0}: {1}", audioFile.FilePath, ex); } return null; }); var imageResult = task.Result; if (imageResult != null) { Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { imageAlbum.Source = imageResult; })); } })); }
public async void RefreshCloudDeviceInfo(CloudDeviceInfo device, AudioFile audioFile) { InvokeOnMainThread(() => { lblDeviceName.Text = device.DeviceName; lblPlaylistName.Text = "On-the-fly Playlist"; lblArtistName.Text = device.ArtistName; lblAlbumTitle.Text = device.AlbumTitle; lblSongTitle.Text = device.SongTitle; lblTimestamp.Text = string.Format("Last updated: {0} {1}", device.Timestamp.ToShortDateString(), device.Timestamp.ToLongTimeString()); }); int height = 44; InvokeOnMainThread(() => { try { height = (int)(imageAlbum.Bounds.Height * UIScreen.MainScreen.Scale); UIView.Animate(0.3, () => { imageAlbum.Alpha = 0; }); } catch(Exception ex) { Console.WriteLine("PlayerViewController - RefreshSongInformation - Failed to set image view album art alpha: {0}", ex); } }); // Load album art + resize in another thread var task = Task<UIImage>.Factory.StartNew(() => { try { byte[] bytesImage = AudioFile.ExtractImageByteArrayForAudioFile(audioFile.FilePath); using (NSData imageData = NSData.FromArray(bytesImage)) { using (UIImage imageFullSize = UIImage.LoadFromData(imageData)) { if (imageFullSize != null) { try { UIImage imageResized = CoreGraphicsHelper.ScaleImage(imageFullSize, height); return imageResized; } catch (Exception ex) { Console.WriteLine("Error resizing image " + audioFile.ArtistName + " - " + audioFile.AlbumTitle + ": " + ex.Message); } } } } } catch (Exception ex) { Console.WriteLine("StartResumePlaybackViewController - RefreshCloudDeviceInfo - Failed to process image: {0}", ex); } return null; }); //}).ContinueWith(t => { UIImage image = await task; if(image == null) return; InvokeOnMainThread(() => { try { imageAlbum.Alpha = 0; imageAlbum.Image = image; UIView.Animate(0.3, () => { imageAlbum.Alpha = 1; }); } catch(Exception ex) { Console.WriteLine("StartResumePlaybackViewController - RefreshCloudDeviceInfo - Failed to set image after processing: {0}", ex); } }); //}, TaskScheduler.FromCurrentSynchronizationContext()); }
public virtual void BindPlayerView(MobileNavigationTabType tabType, IPlayerView view) { _playerView = view; _playerView.OnViewDestroy = (view2) => { _playerPresenter.ViewDestroyed(); _playerPresenter = null; _playerView = null; }; _playerPresenter = Bootstrapper.GetContainer().Resolve<IPlayerPresenter>(); _playerPresenter.BindView(view); // Create sub views var playerMetadata = CreatePlayerMetadataView(); var loops = CreateLoopsView(); var markers = CreateMarkersView(); var timeShifting = CreateTimeShiftingView(); var pitchShifting = CreatePitchShiftingView(); _playerView.PushSubView(playerMetadata); _playerView.PushSubView(loops); _playerView.PushSubView(markers); _playerView.PushSubView(timeShifting); _playerView.PushSubView(pitchShifting); // Check if the Start Resume Playback view must be shown after startup if (_resumeCloudDeviceInfo != null) { Tracing.Log("MobileNavigationManager - BindPlayerView - showing Start Resume Playback view..."); var startResumePlaybackView = CreateStartResumePlaybackView(); PushDialogView(MobileDialogPresentationType.Overlay, "Resume Playback", _playerView, startResumePlaybackView); _resumeCloudDeviceInfo = null; } }
private void ContinueAfterSplash() { AppConfigManager.Instance.Load(); #if IOS CreateMobileMainView(); #endif //Tracing.Log("MobileNavigationManager - ContinueAfterSplash - isFirstRun: {0} resumePlayback.currentAudioFileId: {1} resumePlayback.currentPlaylistId: {2} resumePlayback.positionPercentage: {3}", AppConfigManager.Instance.Root.IsFirstRun, AppConfigManager.Instance.Root.ResumePlayback.AudioFileId, AppConfigManager.Instance.Root.ResumePlayback.PlaylistId, AppConfigManager.Instance.Root.ResumePlayback.PositionPercentage); bool didCreateView = false; if (AppConfigManager.Instance.Root.IsFirstRun) { //Tracing.Log("MobileNavigationManager - ContinueAfterSplash - First run of the application; launching FirstRun activity..."); CreateFirstRunView(); didCreateView = true; } else if (!string.IsNullOrEmpty(AppConfigManager.Instance.Root.ResumePlayback.AudioFileId)) { var resumePlaybackService = Bootstrapper.GetContainer().Resolve<IResumePlaybackService>(); _resumeCloudDeviceInfo = resumePlaybackService.GetResumePlaybackInfo(); if (_resumeCloudDeviceInfo != null) { CreatePlayerView(MobileNavigationTabType.Playlists); didCreateView = true; } } #if ANDROID if(!didCreateView) CreateMobileMainView(); #endif // Shouldn't this be done by the presenter instead, who notifies the view? This should be the ONLY view that the NavMgr calls directly... _splashView.DestroyView(); }
public void RefreshCloudDeviceInfo(CloudDeviceInfo info, AudioFile audioFile) { InvokeOnMainThread(() => { lblDeviceName.StringValue = info.DeviceName; lblArtistName.StringValue = audioFile.ArtistName; lblAlbumTitle.StringValue = audioFile.AlbumTitle; lblSongTitle.StringValue = audioFile.Title; lblLastUpdated.StringValue = string.Format("Last updated: {0}", info.Timestamp); SyncDeviceType deviceType = SyncDeviceType.Unknown; Enum.TryParse<SyncDeviceType>(info.DeviceType, out deviceType); LoadDeviceIcon(deviceType); LoadAlbumArt(audioFile); }); }
public void RefreshCloudDeviceInfo(CloudDeviceInfo info, AudioFile audioFile) { Activity.RunOnUiThread(() => { _lblDeviceName.Text = info.DeviceName; _lblPlaylistName.Text = "On-the-fly playlist"; _lblArtistName.Text = info.ArtistName; _lblAlbumTitle.Text = info.AlbumTitle; _lblSongTitle.Text = info.SongTitle; _lblTimestamp.Text = string.Format("Last updated: {0} {1}", info.Timestamp.ToShortDateString(), info.Timestamp.ToLongTimeString()); }); }
public StartResumePlaybackFragment(CloudDeviceInfo device) : base() { _device = device; }
public virtual ISplashView CreateSplashView() { // The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view. Action onInitDone = () => { Tracing.Log("SplashInitDone"); try { var resumePlaybackService = Bootstrapper.GetContainer().Resolve<IResumePlaybackService>(); _resumeCloudDeviceInfo = resumePlaybackService.GetResumePlaybackInfo(); CreateMainView(); if(_resumeCloudDeviceInfo != null) CreateStartResumePlaybackView(); } catch(Exception ex) { Tracing.Log("NavigationManager - CreateMainView - Exception: {0}", ex); throw; } }; Action<IBaseView> onViewReady = (view) => { _splashPresenter = Bootstrapper.GetContainer().Resolve<ISplashPresenter>(); _splashPresenter.BindView((ISplashView)view); _splashPresenter.Initialize(onInitDone); // TODO: Should the presenter call NavMgr instead of using an action? }; _splashView = Bootstrapper.GetContainer().Resolve<ISplashView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } }); _splashView.OnViewDestroy = (view) => { _splashPresenter.ViewDestroyed(); _splashPresenter = null; _splashView = null; }; return _splashView; }
public void PushDeviceInfo(AudioFile audioFile, long positionBytes, string position) { if (!HasLinkedAccount) throw new CloudAppNotLinkedException(); Task.Factory.StartNew(() => { var device = new CloudDeviceInfo() { AudioFileId = audioFile.Id, ArtistName = audioFile.ArtistName, AlbumTitle = audioFile.AlbumTitle, SongTitle = audioFile.Title, Position = position, PositionBytes = positionBytes, DeviceType = _deviceSpecifications.GetDeviceType().ToString(), DeviceName = _deviceSpecifications.GetDeviceName(), DeviceId = _deviceSpecifications.GetDeviceUniqueId(), IPAddress = _deviceSpecifications.GetIPAddress(), Timestamp = DateTime.Now }; string json = JsonConvert.SerializeObject(device); byte[] bytes = Encoding.UTF8.GetBytes(json); _cloudService.UploadFile(string.Format("/Devices/{0}.json", device.DeviceId), bytes); }); }