示例#1
0
 private void Play(MediaPlayerPlaylistItem song, bool playedByUser)
 {
     this.jsRuntime.MediaPlayerSetSource(song.PlayableUrl);
     this.jsRuntime.MediaPlayerPlay();
     this.Change();
     try
     {
         this.apiClient.TelemetrySongPlay(
             new SongPlayTelemetryRequest
         {
             SessionId = this.applicationState.SessionId, SongId = song.Id, PlayedByUser = playedByUser,
         });
     }
     catch
     {
     }
 }
示例#2
0
        public void AddAndPlay(MediaPlayerPlaylistItem song)
        {
            var existingSong = this.Playlist.FirstOrDefault(x => x.Id == song.Id);

            if (existingSong != null)
            {
                // Song already in the playlist
                this.CurrentIndexInThePlaylist = this.Playlist.IndexOf(existingSong);
            }
            else
            {
                this.Playlist.Add(song);
                this.CurrentIndexInThePlaylist = this.Playlist.Count - 1;
            }

            this.Play(song, true);
        }
示例#3
0
        public void RemoveSong(MediaPlayerPlaylistItem song)
        {
            var songToRemove = this.Playlist.FirstOrDefault(x => x.Id == song.Id);

            if (songToRemove == null)
            {
                return;
            }

            var index = this.Playlist.IndexOf(songToRemove);

            this.Playlist.Remove(songToRemove);
            if (index < this.CurrentIndexInThePlaylist)
            {
                this.CurrentIndexInThePlaylist--;
            }

            this.Change();
        }