示例#1
0
 public async Task SendPlaylist(PlaylistUpdateDTO dto)
 {
     try
     {
         await this.playHub.Clients.All.SendPlaylist(dto);
     }
     catch (Exception xe)
     {
         log.Error(xe);
     }
 }
示例#2
0
        public async Task ClearPlaylist(string deviceKey)
        {
            var dr = GetDeviceRuntime(deviceKey);

            if (dr != null)
            {
                dr.Playlist.Items.Clear();
                //dr.CurrentPlaylistSequenceNumber = 0;
                //dr.CurrentPSN = (0, 0);
                dr.CurrentPosition.Reset();
                var dto = new PlaylistUpdateDTO
                {
                    DeviceKey   = deviceKey,
                    DisplayName = dr.DisplayName,
                    Items       = dr.Playlist.Items.Select(x => x.ToDTO())
                };
                await SendPlaylist(dto);
            }
        }
示例#3
0
 public async Task AddPlaylistItem(string deviceKey, PlaylistItem pli)
 {
     using (var scope = new ScopedDbContext <MusicDb>(serviceProvider))
     {
         var dr = GetDeviceRuntime(deviceKey);
         if (dr != null)
         {
             var item = pli.ToRuntime(scope.Db, dr);
             if (item != null)
             {
                 dr.Playlist.Items.Add(pli.ToRuntime(scope.Db, dr));
                 var dto = new PlaylistUpdateDTO
                 {
                     DeviceKey = deviceKey,
                     Items     = dr.Playlist.Items.Select(x => x.ToDTO())
                 };
                 await SendPlaylist(dto);
             }
         }
     }
 }