private void AMixIsPlayed() { playbackController.Play(new Mix(new MixElement(), 0) { CoverUri = coverUri1, Name = mixName1 }); }
static void Main(string[] args) { var controller = new PlaybackController(); controller.MediaOpening += (s, e) => { $"EVT: {nameof(controller.MediaOpening)}".Info(typeof(Program)); }; controller.MediaOpened += (s, e) => { $"EVT: {nameof(controller.MediaOpened)}".Info(typeof(Program)); }; controller.BufferingStarted += (s, e) => { $"EVT: {nameof(controller.BufferingStarted)}".Info(typeof(Program)); }; controller.BufferingEnded += (s, e) => { $"EVT: {nameof(controller.BufferingEnded)}".Info(typeof(Program)); }; controller.MediaBlockAvailable += (s, e) => { $"EVT: {nameof(controller.MediaBlockAvailable)} | {e.Block.MediaType,8} | {e.Position.TotalSeconds,6:0.00}".Trace(typeof(Program)); }; controller.MediaEnded += (s, e) => { $"EVT: {nameof(controller.MediaEnded)} | POS: {controller.Position.TotalSeconds,8:0.00}".Info(typeof(Program)); }; var hasSeeked = false; controller.PropertyChanged += (s, e) => { if (hasSeeked == false && controller.Position.TotalSeconds >= 3) { hasSeeked = true; controller.Position = TimeSpan.FromSeconds(40); controller.SpeedRatio = 3.0d; } }; controller.Open(TestInputs.MatroskaLocalFile); controller.Play(); Terminal.ReadKey(true, true); }
public async void TogglePlay(object sender, EventArgs arg) { if (MediaPlayer.State == MediaPlayerState.Playing) { await PlaybackController.Pause(); } else { await PlaybackController.Play(); } }
public override void SwitchedToLocalPlayback(NSObject lastKnownStreamPosition, NSObject error) { //base.SwitchedToLocalPlayback(lastKnownStreamPosition, error); var x = (NSNumber)lastKnownStreamPosition; if (x.Int32Value > 0) { PlaybackController.Play(); } Debug.WriteLine("Switched to Local Playback"); }
internal void Play() { if (Microsoft.MediaCenter.UI.Application.ApplicationThread != System.Threading.Thread.CurrentThread) { Application.UIDeferredInvokeIfRequired(() => Play()); return; } System.Diagnostics.Debug.Assert(Microsoft.MediaCenter.UI.Application.ApplicationThread == Thread.CurrentThread); Prepare(); if (!MediaItems.Any() && !Files.Any()) { Microsoft.MediaCenter.MediaCenterEnvironment ev = Application.MediaCenterEnvironment; ev.Dialog(Application.CurrentInstance.StringData("NoContentDial"), Application.CurrentInstance.StringData("Playstr"), Microsoft.MediaCenter.DialogButtons.Ok, 500, true); return; } if (CurrentMedia != null) { Logger.ReportInfo(string.Format("{0} about to play {1}({2}) ", PlaybackController.ControllerName, DisplayName, CurrentMedia.Files.FirstOrDefault())); } // If the controller already has active playable items, stop it and wait for it to flush out if (!QueueItem) { PlaybackController.StopAndWait(); } // Run all pre-play processes RunPrePlayProcesses(); if (!QueueItem && StopAllPlaybackBeforePlaying) { StopAllApplicationPlayback(); } if (UseAutoPlay) { Logger.ReportVerbose("Playing with autoplay. Marking watched since we have no way of getting status on this."); MarkWatchedIfNeeded(); } else { //AdjustRefreshRate(); PlaybackController.Play(this); } }
public NowPlayingViewModel() { _playbackController = IoC.Get <PlaybackController>(); SelectionChangedCommand = new ReactiveCommand(); SelectionChangedCommand.Where(x => x != null) .Select(x => ((IEnumerable)x).Cast <TrackStateViewModel>()) .Subscribe(x => SelectedItems = x); RemoveSelectedCommand = new ReactiveCommand(); RemoveSelectedCommand.Subscribe(param => new List <TrackStateViewModel>(SelectedItems) .ForEach(x => Playlist.Remove(x))); RemoveAllCommand = new ReactiveCommand(); RemoveAllCommand.Subscribe(param => Playlist.Clear()); PlaySelectedCommand = new ReactiveCommand(); PlaySelectedCommand.Subscribe(param => _playbackController.Play(SelectedItems.First())); }
public NowPlayingViewModel() { _playbackController = IoC.Get<PlaybackController>(); SelectionChangedCommand = new ReactiveCommand(); SelectionChangedCommand.Where(x => x != null) .Select(x => ((IEnumerable) x).Cast<TrackStateViewModel>()) .Subscribe(x => SelectedItems = x); RemoveSelectedCommand = new ReactiveCommand(); RemoveSelectedCommand.Subscribe(param => new List<TrackStateViewModel>(SelectedItems) .ForEach(x => Playlist.Remove(x))); RemoveAllCommand = new ReactiveCommand(); RemoveAllCommand.Subscribe(param => Playlist.Clear()); PlaySelectedCommand = new ReactiveCommand(); PlaySelectedCommand.Subscribe(param => _playbackController.Play(SelectedItems.First())); }
internal void Play() { Prepare(); if (!HasMediaItems && !Files.Any()) { Microsoft.MediaCenter.MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; ev.Dialog(Application.CurrentInstance.StringData("NoContentDial"), Application.CurrentInstance.StringData("Playstr"), Microsoft.MediaCenter.DialogButtons.Ok, 500, true); return; } Logger.ReportInfo(PlaybackController.ControllerName + " about to play " + DisplayName); // If the controller already has active playable items, stop it and wait for it to flush out if (!QueueItem) { PlaybackController.StopAndWait(); } // Run all pre-play processes RunPrePlayProcesses(); if (!QueueItem && StopAllPlaybackBeforePlaying) { StopAllApplicationPlayback(); } if (UseAutoPlay) { Logger.ReportVerbose("Playing with autoplay. Marking watched since we have no way of getting status on this."); MarkWatchedIfNeeded(); } else { PlaybackController.Play(this); } }
private async void HandleNotificationActions(object sender, string action) { if (action.Equals(MediaServiceBase.ActionPlay)) { await PlaybackController.Play(); } else if (action.Equals(MediaServiceBase.ActionPause)) { await PlaybackController.Pause(); } else if (action.Equals(MediaServiceBase.ActionPrevious)) { await PlaybackController.PlayPreviousOrSeekToStart(); } else if (action.Equals(MediaServiceBase.ActionNext)) { await PlaybackController.PlayNext(); } else if (action.Equals(MediaServiceBase.ActionStop)) { await Stop(); } }
public void BindEvents() { PlaybackController.MediaItemChanged += PlaybackController_MediaItemChanged; PlaybackController.MediaItemFinished += PlaybackController_MediaItemFinished; PlaybackController.StateChanged += PlaybackController_StateChanged; MediaPlayer.MediaPlayer.BeforePlaying += MediaPlayer_BeforePlaying; element.Stop = () => PlaybackController.Stop(); element.Play = () => PlaybackController.Play(); element.Abort = () => aborted = true; element.Reset = () => aborted = false; element.PlayQueueItem = PlayQueueItem; element.GetCurrentMedia = () => MediaPlayer.MediaQueue.Current != null ? new Realm.Of.Y.Manager.Models.Container.MediaItem(MediaPlayer.MediaQueue.Current.MediaUri) { Title = MediaPlayer.MediaQueue.Current.Title } : null; seeker.ProgressChanged += Seeker_ProgressChanged; youtube_button_prev.Click += (sender, e) => { PlaybackController.PlayPrevious(); element?.OnPrev?.Invoke(); }; youtube_button_next.Click += (sender, e) => { PlaybackController.PlayNext(); element?.OnNext?.Invoke(); }; fullscreen_button.Click += (s, e) => { Fullscreen_button_Click(null, null); }; btnPlay.Click += TogglePlay; element.OnPlayVideo = (items) => PlayVideo(items); element.SetFullScrean = (n) => { fullScrean = !n; Fullscreen_button_Click(null, null); }; }
internal void Play() { Prepare(); if (!MediaItems.Any() && !Files.Any()) { Microsoft.MediaCenter.MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; ev.Dialog(Application.CurrentInstance.StringData("NoContentDial"), Application.CurrentInstance.StringData("Playstr"), Microsoft.MediaCenter.DialogButtons.Ok, 500, true); return; } if (CurrentMedia != null) { Logger.ReportInfo(string.Format("{0} about to play {1}({2}) ", PlaybackController.ControllerName, DisplayName, CurrentMedia.Files.FirstOrDefault())); } // If the controller already has active playable items, stop it and wait for it to flush out if (!QueueItem) { PlaybackController.StopAndWait(); } // Run all pre-play processes RunPrePlayProcesses(); if (!QueueItem && StopAllPlaybackBeforePlaying) { StopAllApplicationPlayback(); } // Play Intros if specified if (PlayIntros && HasMediaItems) { var item = MediaItems.First(); if (item is Movie && (item.DisplayMediaType == null || !item.DisplayMediaType.Equals("trailer", StringComparison.OrdinalIgnoreCase))) { // Get intros for this item var introItems = Kernel.Instance.MB3ApiRepository.RetrieveIntros(MediaItems.First().ApiId).OfType <Video>().ToList(); var intros = introItems.Select(i => i.Files.FirstOrDefault()).ToList(); // Kick off our intro playback controller if (intros.Any()) { Application.CurrentInstance.IntroController.Init(intros); Application.CurrentInstance.IntroController.Play(); //mark them watched Async.Queue("Mark watched", () => { foreach (var i in introItems) { Kernel.ApiClient.UpdatePlayedStatus(i.ApiId, Kernel.CurrentUser.Id, true); } }); } } } if (UseAutoPlay) { Logger.ReportVerbose("Playing with autoplay. Marking watched since we have no way of getting status on this."); MarkWatchedIfNeeded(); } else { PlaybackController.Play(this); } }
public async Task Play() { await PlaybackController.Play(); }
void ExecutePlayCommand(object obj) { GoToPause = true; GoToPlay = false; PlaybackController.Play(); }
private void TheMixIsPlaying() { playbackController.Play(aMix); }