public async Task PlayAsync(NicoVideoQuality quality = NicoVideoQuality.Unknown, TimeSpan startPosition = default) { if (_niconicoVideoSessionProvider == null) { throw new ArgumentException("please call VideoPlayer.UpdatePlayingVideo() before VideoPlayer.PlayAsync()."); } if ((_currentSession as IVideoStreamingSession)?.Quality == quality) { return; } _currentSession?.Dispose(); _currentSession = await _niconicoVideoSessionProvider.CreateVideoSessionAsync(quality); if (_currentSession is IVideoStreamingSession videoStreamingSession) { CurrentQuality = AvailableQualities.First(x => x.Quality == videoStreamingSession.Quality); } if (_currentSession is LocalVideoStreamingSession) { IsPlayWithCache.Value = true; } NowPlayingWithDmcVideo = _currentSession is Models.DmcVideoStreamingSession; await _currentSession.StartPlayback(_mediaPlayer, startPosition); }
void IDisposable.Dispose() { RemoveProgressToast(); Session?.Dispose(); }