private async Task SelectItem(IMediaItem mediaItem) { MediaManager.MediaQueue.Clear(); await MediaManager.Play(mediaItem); /*foreach (var item in Items.Except<string>(new[] { url })) * { * MediaManager.MediaQueue.Add(new MediaItem(item)); * }*/ }
/// <summary> /// Reproducir la señal en directo (TV) /// </summary> public void ReproducirTV() { if (!IsStream) { IsStream = true; GridVideo.Children.RemoveAt(1); GridVideo.Children.Insert(1, CargaVideoTV); mm.StateChanged += Mm_StateChanged; if (youtubePlayer != null) { youtubePlayer.PropertyChanged -= YoutubePlayer_PropertyChanged; } ReproducirVideo("https://593fa17dec176.streamlock.net:455/mirametv/mirametv/master.m3u8"); Controles.InputTransparent = false; } else { mm.Play(); } }
//private Song lastSong; private async void PlaySong(Song obj) { if (Singleton.Instance.lastSong != null) { if (Singleton.Instance.lastSong.SongId != obj.SongId) { await media.Pause(); media.MediaQueue.Clear(); Singleton.Instance.lastSong.IsPlaying = false; Singleton.Instance.lastSong = obj; Singleton.Instance.lastSong.IsPlaying = true; var path = new System.Uri("/assets/music/" + obj.SongAudio).AbsolutePath; await media.Play(Singleton.Instance.AriaUrl + path); } else { if (Singleton.Instance.lastSong.IsPlaying == true) { Singleton.Instance.lastSong.IsPlaying = false; await media.Pause(); } else { Singleton.Instance.lastSong.IsPlaying = true; await media.Play(); } } } else { Singleton.Instance.lastSong = obj; var path = new System.Uri("/assets/music/" + obj.SongAudio).AbsolutePath; await media.Play(Singleton.Instance.AriaUrl + path); Singleton.Instance.lastSong.IsPlaying = true; } }
public static Task PlayPause(this IMediaManager mediaManager) { var status = mediaManager.State; if (status == MediaPlayerState.Paused || status == MediaPlayerState.Stopped) { return(mediaManager.Play()); } else { return(mediaManager.Pause()); } }
private async Task SelectItem(string url) { await mediaManager.Play(url); }
public void Play(PlaylistFile playlist = null, AudioFile audio = null) { //EndsWith(".mp3") if (audio.SourceString.Split("//")[1].Split("/")[0].EndsWith(".mp3")) { Toast.MakeText(Application.Context, "URI трека пришел с ошибкой. Невозможно воспроизвести.", ToastLength.Long).Show(); return; } if (playlist == null) { if (currentPlaylist == null && currentTrack == null) { return; } player.Play(); } else { if (playlist.Id != currentPlaylistId) { var audioPlaylist = new AudioPlaylist(playlist, audio, StaticContentService.RepeatPlaylist, StaticContentService.RepeatTrack); currentPlaylist = audioPlaylist; currentTrack = audio; currentPlaylist.OnCurrentItemChanged += CurrentPlaylistOnOnCurrentItemChanged; CurrentAudioChanged?.Invoke(this, audio); } else { currentPlaylist.SetCurrentTrack(audio); currentTrack = audio; CurrentAudioChanged?.Invoke(this, audio); } //var playerNotificationManager = (CrossMediaManager.Android.NotificationManager as MediaManager.Platforms.Android.Notifications.NotificationManager).PlayerNotificationManager; TaskService.RunOnUI(async() => { Toast.MakeText(Application.Context, "[Отладка] Начинаем воспроизводить...", ToastLength.Long).Show(); Toast.MakeText(Application.Context, $"[Отладка] URI: {currentTrack.SourceString}", ToastLength.Long).Show(); var media = await player.Play(currentTrack.SourceString); media.Title = currentTrack.Title; media.AlbumArtUri = ""; //Без этого треки с битыми ссылками будут выкидывать плеер в фатал media.Artist = currentTrack.Artist; media.AlbumArtist = currentTrack.Artist; media.ArtUri = null; if (currentTrack.Cover != "placeholder") { media.ArtUri = currentTrack.Cover; } CrossMediaManager.Android.NotificationManager.UpdateNotification(); }); //player.MediaQueue.Current.Title = audio.Title; //player.MediaQueue.Current.Artist = audio.Title; //player.MediaQueue.Current.AlbumArtUri = audio.Cover; //CrossMediaManager.Android. //player.NotificationManager = null; } }
private void Button_Clicked_1(object sender, EventArgs e) { //play _mediaManager.Play(new MediaItem("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4")); //MessagingCenter.Instance.Send<object, bool>(this, "PlayerMessage", true); }
public virtual async Task Play() { await _mediaManager.Play(); }