public Task SendPlaystateCommand(PlaystateRequest command, CancellationToken cancellationToken) { switch (command.Command) { case PlaystateCommand.Stop: Playlist.Clear(); return(_device.SetStop()); case PlaystateCommand.Pause: return(_device.SetPause()); case PlaystateCommand.Unpause: return(_device.SetPlay()); case PlaystateCommand.Seek: { return(Seek(command.SeekPositionTicks ?? 0)); } case PlaystateCommand.NextTrack: return(SetPlaylistIndex(_currentPlaylistIndex + 1)); case PlaystateCommand.PreviousTrack: return(SetPlaylistIndex(_currentPlaylistIndex - 1)); } return(Task.FromResult(true)); }
public Task SendPlaystateCommand(PlaystateRequest command, CancellationToken cancellationToken) { switch (command.Command) { case PlaystateCommand.Stop: Playlist.Clear(); return(_device.SetStop()); case PlaystateCommand.Pause: return(_device.SetPause()); case PlaystateCommand.Unpause: return(_device.SetPlay()); case PlaystateCommand.Seek: var playlistItem = Playlist.FirstOrDefault(p => p.PlayState == 1); if (playlistItem != null && playlistItem.Transcode && playlistItem.IsVideo && _currentItem != null) { var newItem = CreatePlaylistItem(_currentItem, command.SeekPositionTicks ?? 0, GetServerAddress()); playlistItem.StartPositionTicks = newItem.StartPositionTicks; playlistItem.StreamUrl = newItem.StreamUrl; playlistItem.Didl = newItem.Didl; return(_device.SetAvTransport(playlistItem.StreamUrl, playlistItem.DlnaHeaders, playlistItem.Didl)); } return(_device.Seek(TimeSpan.FromTicks(command.SeekPositionTicks ?? 0))); case PlaystateCommand.NextTrack: _currentItem = null; return(SetNext()); case PlaystateCommand.PreviousTrack: _currentItem = null; return(SetPrevious()); } return(Task.FromResult(true)); }