public bool OnError(MediaPlayer mp, MediaError error, int extra) { ProgressBar.Visibility = ViewStates.Gone; // only show the resultView if we're active. if (FragmentActive == true) { ResultView.Show(MessagesStrings.Error_Title, PrivateControlStylingConfig.Result_Symbol_Failed, MessagesStrings.Error_Watch_Playback, GeneralStrings.Retry); ResultView.SetBounds(new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels)); } if (mp != null) { mp.Stop( ); mp.Reset( ); } MediaControllerPrepared = false; PlayerState = MediaPlayerState.None; //SyncUI( ); return(true); }
private void SetState(MediaPlayerState state) { MediaPlayerState oldState = State; State = state; StateChanged?.Invoke(this, new StateChangedEventArgs(oldState, state)); }
public void SetState(MediaPlayerState newState) { switch (newState) { case MediaPlayerState.Idle: _Player.Stop(); foreach (RenderHeads.Media.AVProVideo.DisplayUGUI videoProjection in VideoProjections) { videoProjection.color = Color.clear; } break; case MediaPlayerState.Loading: foreach (RenderHeads.Media.AVProVideo.DisplayUGUI videoProjection in VideoProjections) { videoProjection.color = Color.clear; } break; case MediaPlayerState.Playing: foreach (RenderHeads.Media.AVProVideo.DisplayUGUI videoProjection in VideoProjections) { videoProjection.color = _CurrentColor; videoProjection.rectTransform.SetAsLastSibling(); } break; } _PlayerState = newState; }
private static MediaPlayerState BuildOne(IBMDSwitcherMediaPlayer props, AtemStateBuilderSettings updateSettings, bool hasClips) { var state = new MediaPlayerState(); if (hasClips) { state.ClipStatus = new MediaPlayerState.ClipStatusState(); } props.GetSource(out _BMDSwitcherMediaPlayerSourceType type, out uint index); state.Source.SourceType = AtemEnumMaps.MediaPlayerSourceMap.FindByValue(type); state.Source.SourceIndex = index; if (state.ClipStatus != null) { props.GetPlaying(out int playing); state.ClipStatus.Playing = playing != 0; props.GetLoop(out int loop); state.ClipStatus.Loop = loop != 0; if (updateSettings.TrackMediaClipFrames) { props.GetAtBeginning(out int atBegining); state.ClipStatus.AtBeginning = atBegining != 0; props.GetClipFrame(out uint clipFrame); state.ClipStatus.ClipFrame = clipFrame; } } return(state); }
public void OnPrepared(MediaPlayer mp) { Rock.Mobile.Util.Debug.WriteLine("OnPrepared - Audio ready to play"); // now that we know the media player is read, set the controller's player MediaController.SetMediaPlayer(this); MediaControllerPrepared = true; // setup a seek listener mp.SetOnSeekCompleteListener(this); // log the series they tapped on. MessageAnalytic.Instance.Trigger(MessageAnalytic.Listen, Name); // if this is a new video, store the URL if (MobileApp.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl != MediaUrl) { MobileApp.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl = MediaUrl; PlayerState = MediaPlayerState.Playing; mp.Start( ); SyncUI( ); } else { // otherwise, resume where we left off mp.SeekTo((int)MobileApp.Shared.Network.RockMobileUser.Instance.LastStreamingMediaPos); } }
private void SetCrossMediaByState(MediaPlayerState state) { switch (state) { case MediaPlayerState.Stopped: customMediaPlayer.Visibility = ViewStates.Gone; current_title = current_image = string.Empty; SaveCurrentPlayerData(null); break; case MediaPlayerState.Playing: customMediaPlayer.Visibility = ViewStates.Visible; SetSeekBarMaxProgress(); playerPlayPause.SetImageResource(Resource.Drawable.pause_24px); break; case MediaPlayerState.Paused: customMediaPlayer.Visibility = ViewStates.Visible; SetSeekBarMaxProgress(); playerPlayPause.SetImageResource(Resource.Drawable.play_24); break; case MediaPlayerState.Buffering: case MediaPlayerState.Loading: break; } }
private void UpdateTransportControls(MediaPlayerState state) { if (state == MediaPlayerState.Opening || state == MediaPlayerState.Buffering) { return; } if (CurrentTrack != null) { if (state == MediaPlayerState.Playing || state == MediaPlayerState.Opening) { CurrentTrack.Playing = true; PlayButtonVisibility = Visibility.Collapsed; StopButtonVisibility = Visibility.Visible; } else { CurrentTrack.Playing = false; PlayButtonVisibility = Visibility.Visible; StopButtonVisibility = Visibility.Collapsed; } PlayButtonIsEnabled = true; } RefreshBindings(); }
private void SendPlayerState(MediaPlayerState playerState) { string value = Enum.GetName(typeof(MediaPlayerState), playerState); ValueSet valueSet = receivers[playerStatePrimaryKey].GetValueSet(value); Send(valueSet); }
public void TestPlaying() { var handler = CommandGenerator.CreateAutoCommandHandler <MediaPlayerClipStatusSetCommand, MediaPlayerClipStatusGetCommand>("Playing"); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MediaPlayerClips, helper => { var tested = false; var players = GetMediaPlayers(helper); foreach (Tuple <uint, IBMDSwitcherMediaPlayer> player in players) { tested = true; AtemState stateBefore = helper.Helper.BuildLibState(); MediaPlayerState playerState = stateBefore.MediaPlayers[(int)player.Item1]; for (int i = 0; i < 5; i++) { bool playing = i % 2 == 0; playerState.ClipStatus.Playing = playing; helper.SendAndWaitForChange(stateBefore, () => { player.Item2.SetPlaying(playing ? 1 : 0); }); } } Assert.True(tested); }); }
public void TestSource() { AtemMockServerWrapper.Each(_output, _pool, SourceCommandHandler, DeviceTestCases.MediaPlayer, helper => { var tested = false; var players = GetMediaPlayers(helper); foreach (Tuple <uint, IBMDSwitcherMediaPlayer> player in players) { tested = true; AtemState stateBefore = helper.Helper.BuildLibState(); MediaPlayerState playerState = stateBefore.MediaPlayers[(int)player.Item1]; for (int i = 0; i < 5; i++) { MediaPlayerSource type = playerState.Source.SourceType = stateBefore.MediaPool.Clips.Count > 0 ? Randomiser.EnumValue <MediaPlayerSource>() : MediaPlayerSource.Still; uint index = playerState.Source.SourceIndex = Randomiser.RangeInt(20) + 1; helper.SendAndWaitForChange(stateBefore, () => { player.Item2.SetSource(AtemEnumMaps.MediaPlayerSourceMap[type], index); }); } } Assert.True(tested); }); }
public void TestClipFrame() { try { _pool.StateSettings.TrackMediaClipFrames = true; var handler = CommandGenerator.CreateAutoCommandHandler <MediaPlayerClipStatusSetCommand, MediaPlayerClipStatusGetCommand>("ClipFrame"); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MediaPlayerClips, helper => { var tested = false; var players = GetMediaPlayers(helper); foreach (Tuple <uint, IBMDSwitcherMediaPlayer> player in players) { tested = true; AtemState stateBefore = helper.Helper.BuildLibState(); MediaPlayerState playerState = stateBefore.MediaPlayers[(int)player.Item1]; for (int i = 0; i < 5; i++) { uint frame = playerState.ClipStatus.ClipFrame = Randomiser.RangeInt(40); helper.SendAndWaitForChange(stateBefore, () => { player.Item2.SetClipFrame(frame); }); } } Assert.True(tested); }); } finally { _pool.StateSettings.TrackMediaClipFrames = false; } }
public void OnSeekComplete(MediaPlayer mp) { PlayerState = MediaPlayerState.Playing; mp.Start( ); SyncUI( ); }
protected override async void LoadState(object param, Dictionary <string, object> pageState) { base.LoadState(param, pageState); int id = (int)param; VideoDataItem item = VideoDataSource.GetItem(id); if (item != null) { OpenFile(item.File); } else if (pageState["fileToken"] != null) { StorageItemAccessList future = StorageApplicationPermissions.FutureAccessList; StorageFile file = await future.GetFileAsync(pageState["fileToken"] as string); future.Clear(); OpenFile(file); } if (pageState != null) { MediaPlayerState state = pageState["MediaState"] as MediaPlayerState; if (state != null) { MediaPlayer.RestorePlayerState(state); } } }
protected virtual async void OnPlaybackStateChanged(MediaPlayerState state) { await DispatcherHelper.RunAsync( () => { PlaybackStateChanged?.Invoke(this, new PlaybackStateEventArgs(state)); }); }
private static void SendPlayerStateChanged(MediaPlayerState state) { MessageModel _sendData = new MessageModel(); _sendData.Type = MessageType.PlayerStateChanged; _sendData.Content = CryptographicBuffer.ConvertStringToBinary(state.ToString(), BinaryStringEncoding.Utf8); _sendData.ContentLength = _sendData.Content.Capacity; SendData(_sendData); }
private async void DidFinishPlaying(NSNotification obj) { var succesfullNext = await MediaManager.PlayNext(); if (!succesfullNext) { State = MediaPlayerState.Stopped; } }
protected virtual void OnPlaybackStateChanged(MediaPlayerState state) { DispatcherHelper.RunAsync(() => { var handler = PlaybackStateChanged; if (handler != null) { handler(this, new PlaybackStateEventArgs(state)); } }); }
public Task Play(IMediaItem mediaItem) { var item = mediaItem.GetPlayerItem(); Player.ActionAtItemEnd = AVPlayerActionAtItemEnd.None; Player.ReplaceCurrentItemWithPlayerItem(item); Player.Play(); State = MediaPlayerState.Playing; return(Task.CompletedTask); }
public void TogglePlayPause() { if (State == MediaPlayerState.Playing) { State = MediaPlayerState.Paused; } else if (State == MediaPlayerState.Paused) { State = MediaPlayerState.Playing; } }
private void UpdateStatus(MediaPlayerState status) { if (CurrentState != status) { CurrentState = status; if (StatusChanged != null) { StatusChanged(this, CurrentState); } } }
private void UpdateTransportControls(MediaPlayerState state) { if (state == MediaPlayerState.Playing) { playButton.Content = "| |"; // Change to pause button } else { playButton.Content = ">"; // Change to play button } }
private void UpdateTransportControls(MediaPlayerState state) { if (state == MediaPlayerState.Playing) { Pause.Icon = new SymbolIcon(Symbol.Pause); // Change to pause button } else { Pause.Icon = new SymbolIcon(Symbol.Play); // Change to play button } }
private void UpdateTransportControls(MediaPlayerState state) { if (state == MediaPlayerState.Playing) { // Change to pause button } else { // Change to play button } }
public void ServiceConnected(AudioServiceBinder binder) { Rock.Mobile.Util.Debug.WriteLine("ServiceConnected."); AudioServiceBinder = binder; if (PlayerState == MediaPlayerState.WantsAutoplay) { StartAudio( ); PlayerState = MediaPlayerState.Preparing; } }
public async void NotifyControllerStateChanged(MediaPlayerState state) { await DispatcherHelper.RunAsync(() => { switch (state) { case MediaPlayerState.Closed: CanPlay = CanPause = false; IsPlaying = false; PlaybackStatus = MediaPlaybackStatus.Closed; SuspendAskPosition(); break; case MediaPlayerState.Opening: CanPlay = CanPause = false; IsPlaying = false; PlaybackStatus = MediaPlaybackStatus.Changing; break; case MediaPlayerState.Buffering: CanPlay = CanPause = false; IsPlaying = false; PlaybackStatus = MediaPlaybackStatus.Changing; break; case MediaPlayerState.Playing: CanPause = true; CanPlay = true; IsPlaying = true; PlaybackStatus = MediaPlaybackStatus.Playing; ResumeAskPosition(); break; case MediaPlayerState.Paused: CanPause = false; CanPlay = true; IsPlaying = false; PlaybackStatus = MediaPlaybackStatus.Paused; SuspendAskPosition(); break; case MediaPlayerState.Stopped: PlaybackStatus = MediaPlaybackStatus.Stopped; SuspendAskPosition(); break; default: break; } }); }
private void SetupCurrentMediaPlayerState(MediaPlayerState currentPlayerState) { LabelPlayerStatus.Text = $"{currentPlayerState.ToString().ToUpper()}"; if (currentPlayerState == MediaManager.Player.MediaPlayerState.Loading) { SliderSongPlayDisplay.Value = 0; } else if (currentPlayerState == MediaManager.Player.MediaPlayerState.Playing && CrossMediaManager.Current.Duration.Ticks > 0) { SliderSongPlayDisplay.Maximum = CrossMediaManager.Current.Duration.Ticks; } }
protected override void SaveState(Dictionary <string, object> pageState) { MediaPlayerState state = MediaPlayer.GetPlayerState(); StorageItemAccessList future = StorageApplicationPermissions.FutureAccessList; future.Clear(); string token = future.Add(file); pageState.Add("MediaState", state); pageState.Add("fileToken", token); base.SaveState(pageState); if (teardown) { MediaPlayer.Dispose(); } }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Rock.Mobile.Util.Debug.WriteLine("OnCreate - Starting Audio Service"); // flag that we want to automatically start the audio. // If this fragment is backgrounded and resumed, this will be false and we won't // attempt to play a second time. PlayerState = MediaPlayerState.WantsAutoplay; // start our audio service Activity.StartService(new Intent(Activity, typeof(AudioService))); // create our connector that manages the interface between us and the service AudioServiceConnection = new AudioServiceConnection(this); }
private void PlayerServiceOnMediaStateChanged(object sender, MediaPlayerState mediaPlayerState) { var icon = Symbol.Play; switch (mediaPlayerState) { case MediaPlayerState.Playing: icon = Symbol.Pause; _timer.Start(); break; default: _timer.Stop(); break; } PlayPauseIcon = new SymbolIcon(icon); }
protected virtual void OnStateChanged(MediaPlayerState e) { if (e != MediaPlayerState.None && e != MediaPlayerState.Stopped) { StartForeground(NotificationId, BuildNotification()); } else { StopForeground(true); } var handler = StateChanged; if (handler != null) { handler(this, new PlaybackStateEventArgs(e)); } }
private void PlayPauseButton_Click(object sender, RoutedEventArgs e) { var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); ((Window.Current.Content as Frame).Content as MainPage).PlayPauseButtonOnLeft_Click(null, null); if (NowState == MediaPlayerState.Playing) { NowState = MediaPlayerState.Paused; ToolTipService.SetToolTip(PlayPauseButton, loader.GetString("PauseTip.Text")); var icon = new BitmapIcon(); icon.UriSource = new Uri("ms-appx:///Assets/ButtonIcon/playsolid.png"); PlayPauseButton.Content = icon; return; } if (NowState == MediaPlayerState.Paused || NowState == MediaPlayerState.Stopped) { NowState = MediaPlayerState.Playing; ToolTipService.SetToolTip(PlayPauseButton, loader.GetString("PlayTip.Text")); var icon = new BitmapIcon(); icon.UriSource = new Uri("ms-appx:///Assets/ButtonIcon/pausesolid.png"); PlayPauseButton.Content = icon; return; } }
private async void BackgroundMediaPlayer_MessageReceivedFromBackground(object sender, MediaPlayerDataReceivedEventArgs e) { BackPlaybackChangedMessage message; if (MessageService.TryParseMessage(e.Data, out message)) { if (message.CurrentSong != null) { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.DispatchedHandler(() => { CurrentSong = message.CurrentSong; updateui(); })); } NowState = message.NowState; } UpdateArtworkMessage artwork; if (MessageService.TryParseMessage(e.Data, out artwork)) { var stream = FileHelper.ToStream(artwork.ByteStream); await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(async () => { MainColor = await BitmapHelper.New(stream); PlayPauseButton.Background = new SolidColorBrush(MainColor); })); } NowListMessage nowList; if (MessageService.TryParseMessage(e.Data, out nowList)) { UpdateNowList(nowList); } FullFileDetailsMessage detail; if (MessageService.TryParseMessage(e.Data, out detail)) { updatedetail(detail); } }
public void setPlaybackControl(MediaPlayerState state) { var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); var t = (TextBlock)ToolTipService.GetToolTip(PlayPauseButton); switch (state) { case MediaPlayerState.Closed: break; case MediaPlayerState.Opening: break; case MediaPlayerState.Buffering: break; case MediaPlayerState.Playing: ProgressSlider.IsEnabled = true; (PlayPauseButton.FindName("PlayPauseSymbolLeft") as SymbolIcon).Symbol = Symbol.Pause; t.Text = loader.GetString("PauseTip.Text"); break; case MediaPlayerState.Paused: (PlayPauseButton.FindName("PlayPauseSymbolLeft") as SymbolIcon).Symbol = Symbol.Play; t.Text = loader.GetString("PlayTip.Text"); break; case MediaPlayerState.Stopped: ProgressSlider.IsEnabled = false; (PlayPauseButton.FindName("PlayPauseSymbolLeft") as SymbolIcon).Symbol = Symbol.Play; t.Text = loader.GetString("PlayTip.Text"); break; default: break; } }
public VlcService(HistoryService historyService) { CurrentState = MediaPlayerState.Stopped; _historyService = historyService; }
public void ServiceConnected( AudioServiceBinder binder ) { Rock.Mobile.Util.Debug.WriteLine( "ServiceConnected." ); AudioServiceBinder = binder; if ( PlayerState == MediaPlayerState.WantsAutoplay ) { StartAudio( ); PlayerState = MediaPlayerState.Preparing; } }
public void PlayPauseButtonOnLeft_Click(object sender, RoutedEventArgs e) { switch (NowState) { case MediaPlayerState.Closed: break; case MediaPlayerState.Opening: break; case MediaPlayerState.Buffering: break; case MediaPlayerState.Playing: MessageService.SendMessageToBackground(new ForePlaybackChangedMessage(PlaybackState.Paused)); NowState = MediaPlayerState.Paused; break; case MediaPlayerState.Paused: MessageService.SendMessageToBackground(new ForePlaybackChangedMessage(PlaybackState.Playing)); NowState = MediaPlayerState.Playing; break; case MediaPlayerState.Stopped: MessageService.SendMessageToBackground(new ForePlaybackChangedMessage(PlaybackState.Playing)); NowState = MediaPlayerState.Playing; break; default: break; } }
protected virtual void OnStateChanged(MediaPlayerState e) { if (e != MediaPlayerState.None && e != MediaPlayerState.Stopped) StartForeground(NotificationId, BuildNotification()); else StopForeground(true); var handler = StateChanged; if (handler != null) handler(this, new PlaybackStateEventArgs(e)); }
private void ChangeState(FileType type, MediaPlayerState state) { if (type == FileType.Audio) { AudioState = state; } else { VideoState = state; } }
private void player_StateChanged(object sender, MediaPlayerState e) { context.Post(new SendOrPostCallback((o) => { switch (e) { case MediaPlayerState.Opening: break; case MediaPlayerState.Buffering: break; case MediaPlayerState.Playing: timer.Start(); playButton.Icon = new SymbolIcon(Symbol.Pause); break; case MediaPlayerState.Paused: case MediaPlayerState.Stopped: case MediaPlayerState.Closed: timer.Stop(); playButton.Icon = new SymbolIcon(Symbol.Play); break; default: break; } posSlider.Value = Player.Instance.RelativePosition; }), null); }
void RefreshUi(MediaPlayerState currentState, string track) { Debug.WriteLine("MainPage.RefreshUi({0}, {1}) {2}", currentState, track, _mediaPlayerHandle.Id); txtCurrentTrack.Text = track ?? string.Empty; txtCurrentState.Text = currentState.ToString(); playButton.Content = MediaPlayerState.Playing == currentState ? "| |" : ">"; if (MediaPlayerState.Opening == currentState) { //prevButton.IsEnabled = false; playButton.IsEnabled = false; //nextButton.IsEnabled = false; } else { prevButton.IsEnabled = true; playButton.IsEnabled = true; nextButton.IsEnabled = true; } var needTimer = MediaPlayerState.Closed != currentState; if (needTimer == _timer.IsEnabled) return; if (needTimer) _timer.Start(); else _timer.Stop(); }
public PlaybackStateEventArgs(MediaPlayerState state) { State = state; }
protected virtual void OnPlaybackStateChanged(MediaPlayerState state) { DispatcherHelper.RunAsync( () => { var handler = PlaybackStateChanged; if (handler != null) { handler(this, new PlaybackStateEventArgs(state)); } }); }
private void StopButton_Click(object sender, RoutedEventArgs e) { ((Window.Current.Content as Frame).Content as MainPage).StopButton_Click(null, null); NowState = MediaPlayerState.Stopped; var icon = new BitmapIcon(); icon.UriSource = new Uri("ms-appx:///Assets/ButtonIcon/playsolid.png"); PlayPauseButton.Content = icon; }
public bool OnError( MediaPlayer mp, MediaError error, int extra ) { ProgressBar.Visibility = ViewStates.Gone; // only show the resultView if we're active. if( FragmentActive == true ) { ResultView.Show( MessagesStrings.Error_Title, PrivateControlStylingConfig.Result_Symbol_Failed, MessagesStrings.Error_Watch_Playback, GeneralStrings.Retry ); ResultView.SetBounds( new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ) ); } if( mp != null ) { mp.Stop( ); mp.Reset( ); } MediaControllerPrepared = false; PlayerState = MediaPlayerState.None; //SyncUI( ); return true; }
private void PlayPauseButton_Loaded(object sender, RoutedEventArgs e) { var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); var t = (TextBlock)ToolTipService.GetToolTip(PlayPauseButton); NowState = BackgroundMediaPlayer.Current.CurrentState; switch (NowState) { case MediaPlayerState.Closed: break; case MediaPlayerState.Opening: break; case MediaPlayerState.Buffering: break; case MediaPlayerState.Playing: t.Text = loader.GetString("PlayTip.Text"); var icon = new BitmapIcon(); icon.UriSource = new Uri("ms-appx:///Assets/ButtonIcon/pausesolid.png"); PlayPauseButton.Content = icon; break; case MediaPlayerState.Paused: t.Text = loader.GetString("PauseTip.Text"); var noci = new BitmapIcon(); noci.UriSource = new Uri("ms-appx:///Assets/ButtonIcon/playsolid.png"); PlayPauseButton.Content = noci; break; case MediaPlayerState.Stopped: break; default: break; } }
public void OnSeekComplete( MediaPlayer mp ) { PlayerState = MediaPlayerState.Playing; mp.Start( ); SyncUI( ); }
private async void BackgroundMediaPlayer_MessageReceivedFromBackground(object sender, MediaPlayerDataReceivedEventArgs e) { BackgroundConfirmFilesMessage confirming; if (MessageService.TryParseMessage(e.Data, out confirming)) { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { LoadingFilesBar.IsIndeterminate = false; LoadingFilesBar.Visibility = Visibility.Collapsed; }); } BackPlaybackChangedMessage stateChangedMessage; if (MessageService.TryParseMessage(e.Data, out stateChangedMessage)) { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // If playback stopped then clear the UI if (stateChangedMessage.CurrentSong == null) { playbackControl.setPlaybackControlDefault(); } else { playbackControl.setPlaybackControl(stateChangedMessage.CurrentSong); this.CurrentSong = stateChangedMessage.CurrentSong; nowPlayingHub.Set(stateChangedMessage.CurrentSong); if (NowLrcFrame.Content != null) { NowLrcFrame.Navigate(typeof(LrcPage), CurrentSong); } } NowState = stateChangedMessage.NowState; BackgroundMediaPlayer.Current.Volume = VolumeSlider.Value / 100.0; var converter = ProgressSlider.ThumbToolTipValueConverter as ThumbToolTipConveter; converter.sParameter = stateChangedMessage.CurrentSong.Duration.TotalSeconds; ArtworkLoadingRing.IsActive = true; ArtworkLoadingRing.Visibility = Visibility.Visible; }); } FileNotFindMessage notfind; if (MessageService.TryParseMessage(e.Data, out notfind)) { this.Dispatcher.RunAsync(CoreDispatcherPriority.High, new DispatchedHandler(() => { FileErrPanel.Visibility = Visibility.Visible; ErrPanelIn.Begin(); ThreadPoolTimer.CreateTimer((a) => { this.Dispatcher.RunAsync(CoreDispatcherPriority.High, new DispatchedHandler(async () => { ErrPanelOut.Begin(); await Task.Delay(256); FileErrPanel.Visibility = Visibility.Collapsed; })); }, TimeSpan.FromSeconds(3)); })); } UpdateArtworkMessage updateartwork; if (MessageService.TryParseMessage(e.Data, out updateartwork)) { IRandomAccessStream stream; stream = await FileHelper.ToRandomAccessStream(updateartwork.ByteStream); this.ArtworkStream = updateartwork.ByteStream; this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ArtworkLoadingRing.IsActive = false; ArtworkLoadingRing.Visibility = Visibility.Collapsed; BitmapImage image = new BitmapImage(); image.SetSource(stream); PlayBackImage.Source = image; PlayBackImage_ImageOpened(stream); }); } }
public void OnPrepared( MediaPlayer mp ) { Rock.Mobile.Util.Debug.WriteLine( "OnPrepared - Audio ready to play" ); // now that we know the media player is read, set the controller's player MediaController.SetMediaPlayer( this ); MediaControllerPrepared = true; // setup a seek listener mp.SetOnSeekCompleteListener( this ); // log the series they tapped on. MessageAnalytic.Instance.Trigger( MessageAnalytic.Listen, Name ); // if this is a new video, store the URL if ( App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl != MediaUrl ) { App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl = MediaUrl; PlayerState = MediaPlayerState.Playing; mp.Start( ); SyncUI( ); } else { // otherwise, resume where we left off mp.SeekTo( (int)App.Shared.Network.RockMobileUser.Instance.LastStreamingMediaPos ); } }
public void StopButton_Click(object sender, RoutedEventArgs e) { MessageService.SendMessageToBackground(new ForePlaybackChangedMessage(PlaybackState.Stopped)); NowState = MediaPlayerState.Stopped; CurrentSong = null; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return null; } RelativeLayout view = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context ); view.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent ); view.SetBackgroundColor( Android.Graphics.Color.Black ); view.SetOnTouchListener( this ); ProgressBar = new ProgressBar( Rock.Mobile.PlatformSpecific.Android.Core.Context ); ProgressBar.Indeterminate = true; ProgressBar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( 0 ) ); ProgressBar.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent ); ( (RelativeLayout.LayoutParams)ProgressBar.LayoutParameters ).AddRule( LayoutRules.CenterInParent ); view.AddView( ProgressBar ); // setup our media controller for viewing the position of media MediaController = new MediaController( Rock.Mobile.PlatformSpecific.Android.Core.Context ); MediaController.SetAnchorView( view ); ResultView = new UIResultView( view, new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ), delegate { // we know we're bound, so now just retry. ResultView.Hide( ); PlayerState = MediaPlayerState.Preparing; StartAudio( ); SyncUI( ); }); return view; }
void Instance_CurrentStateChanged(object sender, RoutedEventArgs e) { mediaState = Instance.CurrentState; switch (mediaState) { case MediaPlayerState.Playing: Debug.WriteLine("Media State Changed: Playing"); StatusChanged?.Invoke(this, MediaState.Playing); dispatchTimer?.Start(); break; case MediaPlayerState.Paused: Debug.WriteLine("Media State Changed: Paused"); StatusChanged?.Invoke(this, MediaState.Paused); dispatchTimer?.Stop(); break; } }
public override void OnCreate( Bundle savedInstanceState ) { base.OnCreate( savedInstanceState ); Rock.Mobile.Util.Debug.WriteLine( "OnCreate - Starting Audio Service" ); // flag that we want to automatically start the audio. // If this fragment is backgrounded and resumed, this will be false and we won't // attempt to play a second time. PlayerState = MediaPlayerState.WantsAutoplay; // start our audio service Activity.StartService( new Intent( Activity, typeof( AudioService ) ) ); // create our connector that manages the interface between us and the service AudioServiceConnection = new AudioServiceConnection( this ); }
public void Pause() { if (!_mp.IsPlaying) return; _mpState = MediaPlayerState.Pause; _mediaController.Hide(); _mp.Pause(); }
public BackPlaybackChangedMessage(MediaPlayerState now, SongModel song) { CurrentSong = song; NowState = now; }
public void Start() { if (_wasRelease || _mp.IsPlaying) return; if (_state == PrepareState.None) { Prepare(); _shouldStart = true; return; } if (_state == PrepareState.Preparing) _shouldStart = true; else { _mpState = MediaPlayerState.Playing; _mp.Start(); } }
public void Stop() { if (!_mp.IsPlaying) return; _mpState = MediaPlayerState.Stop; _mediaController.Hide(); _mp.Stop(); }
public bool OnError( MediaPlayer mp, MediaError error, int extra ) { ProgressBar.Visibility = ViewStates.Gone; ResultView.Show( MessagesStrings.Error_Title, PrivateControlStylingConfig.Result_Symbol_Failed, MessagesStrings.Error_Watch_Playback, GeneralStrings.Retry ); ResultView.SetBounds( new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ) ); mp.Stop( ); mp.Reset( ); //Activity.UnbindService( AudioServiceConnection ); PlayerState = MediaPlayerState.Stopped; SyncUI( ); return true; }