//void clientByImage_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) //{ // try // { // MediaHistoryItem mediaHistoryItem1 = new MediaHistoryItem(); // mediaHistoryItem1.ImageStream = e.Result; // mediaHistoryItem1.Title = _channelDetailInfo.Title; // mediaHistoryItem1.PlayerContext.Add("HubTag", _channelDetailInfo.VID + "|||" + ProgramIndex); // MediaHistory.Instance.WriteAcquiredItem(mediaHistoryItem1); // e.Result.Position = 0; // MediaHistory.Instance.WriteRecentPlay(mediaHistoryItem1); // } // catch { } //} private void xPPvodWP7MediaElement_BufferingProgressChanged(object sender, PPTVWP7MediaPlayer.PPLiveRoutedEventArgs e) { if (_isDrag) { if (_isNewBuffer) { _preDragBuffer = DateTime.Now; _dragBufferCount++; } else { _dragBufferTime += (DateTime.Now - _preDragBuffer).TotalSeconds; _preDragBuffer = DateTime.Now; } } if (_isNewBuffer) { _preBuffer = DateTime.Now; _isNewBuffer = false; _allBufferCount++; } else { _bufferTime += (DateTime.Now - _preBuffer).TotalSeconds; _preBuffer = DateTime.Now; } int progress = Convert.ToInt32(xPPvodWP7MediaElement.BufferingProgress * 100); if (progress >= 100) { _isNewBuffer = true; _isDrag = false; } if (progress == 100 || xPPvodWP7MediaElement.CurrentState != MediaElementState.Buffering || (xPPvodWP7MediaElement.Position.TotalSeconds > _bufferingPosition)) SetInfo(false); else SetInfo(true, "正在缓冲" + (progress + "%" == "0%" ? "" : progress + "%")); }
private void xPPvodWP7MediaElement_CurrentStateChanged(object sender, PPTVWP7MediaPlayer.PPLiveRoutedEventArgs e) { switch (xPPvodWP7MediaElement.CurrentState) { case MediaElementState.AcquiringLicense: break; case MediaElementState.Buffering: _bufferingPosition = xPPvodWP7MediaElement.Position.TotalSeconds; SetInfo(true, "正在缓冲影片"); SetControlBarStatus(false, true); break; case MediaElementState.Closed: _timer.Stop(); break; case MediaElementState.Individualizing: break; case MediaElementState.Opening: SetInfo(true, "正在打开影片"); BeginSetChannelToVideoHub(ChannelDetailInfo); break; case MediaElementState.Paused: SetControlBarStatus(false, true); break; case MediaElementState.Playing: //判断是否有播放过,如果有播放过 则从用户播放过的位置开始播放 _isDrag = false; if (_isPlayDBPosition) { if (_playLocalFile) { // 接着从上次停止的地方接着观看 LocalPlayFactory localFactory = new LocalPlayFactory(); xPPvodWP7MediaElement.Position = TimeSpan.FromSeconds(localFactory.GetPosition(_localFileId)); } else { var playHistroy = PlayHistoryFactory.Instance.GetEntity(VID); if (playHistroy != null) { _timer.Stop(); if (playHistroy.ProgramIndex == ProgramIndex) xPPvodWP7MediaElement.Position = TimeSpan.FromSeconds(playHistroy.Position); } } } SetControlBarStatus(); SetInfo(false); break; case MediaElementState.Stopped: { _playTime = (DateTime.Now - _beginPlaying).TotalSeconds; _timer.Stop(); SetInfo(false); SetControlBarStatus(false, true); if (!_isAutoStop) { _isAutoStop = false; _playBufferCount = _allBufferCount - _dragBufferCount; PPTVData.Factory.DACPlayInfo playInfo = new PPTVData.Factory.DACPlayInfo(); playInfo.castType = 3; playInfo.stopReason = 0; playInfo.isPlaySucceeded = _isPlaySucceeded ? 1 : 0; playInfo.connType = _connType; playInfo.dragCount = _dragCount; playInfo.playBufferCount = _playBufferCount; playInfo.dragBufferTime = _dragBufferTime; playInfo.allBufferCount = _allBufferCount; playInfo.bufferTime = _bufferTime; playInfo.prepareTime = _prepareTime; playInfo.programSource = _programSource; playInfo.averageDownSpeed = _averageDownSpeed; playInfo.playTime = _playTime; playInfo.mp4Name = Utils.Utils.UrlDecode(_currentPlayBitrate != null ? _currentPlayBitrate.Rid : ""); PPTVData.Factory.DACFactory.DACPlaying(playInfo, ChannelDetailInfo, Utils.Utils.GetClientVersion()); } } break; default: break; } //xDebugTextBlock.Text = xPPvodWP7MediaElement.CurrentState.ToString(); xPlayerControlBar.SetPlayerControlBarStuas(xPPvodWP7MediaElement.CurrentState); if (xPPvodWP7MediaElement.CurrentState != MediaElementState.Buffering) _isDrag = false; }
private void xPPvodWP7MediaElement_OutputLog(object sender, PPTVWP7MediaPlayer.LogEventArgs e) { LogManager.Ins.Log(e.Text); }
private void xPPvodWP7MediaElement_MediaFailed(object sender, PPTVWP7MediaPlayer.PPLiveExceptionRoutedEventArgs e) { if (_playLocalFile) { MessageBox.Show("无法播放该影片"); if (NavigationService.CanGoBack) NavigationService.GoBack(); return; } int oldBitrate = _currentPlayBitrate != null ? _currentPlayBitrate.FileType : -1; if (PlayFirstCondidacyBitrate(true)) { if (oldBitrate == 0 || oldBitrate == 1) { SetInfo(true, "当前高清版本无法播放,正在请求其他版本!"); } return; } Debug.WriteLine("错误异常:" + e.ErrorException.Message); SetInfo(false); _playBufferCount = _allBufferCount - _dragBufferCount; PPTVData.Factory.DACPlayInfo playInfo = new PPTVData.Factory.DACPlayInfo(); playInfo.castType = 3; playInfo.stopReason = 2; playInfo.isPlaySucceeded = _isPlaySucceeded ? 1 : 0; playInfo.connType = _connType; playInfo.dragCount = _dragCount; playInfo.playBufferCount = _playBufferCount; playInfo.dragBufferTime = _dragBufferTime; playInfo.allBufferCount = _allBufferCount; playInfo.bufferTime = _bufferTime; playInfo.prepareTime = _prepareTime; playInfo.programSource = _programSource; playInfo.averageDownSpeed = _averageDownSpeed; playInfo.playTime = _playTime; if (_currentPlayBitrate != null) playInfo.mp4Name = Utils.Utils.UrlDecode(_currentPlayBitrate.Rid); if (ChannelDetailInfo != null) PPTVData.Factory.DACFactory.DACPlaying(playInfo, ChannelDetailInfo, Utils.Utils.GetClientVersion()); _isPlaySucceeded = false; ChannelDetailInfo = null; MessageBox.Show(e.ErrorException.Message); if (NavigationService.CanGoBack) NavigationService.GoBack(); }
private void xPPvodWP7MediaElement_MediaOpened(object sender, PPTVWP7MediaPlayer.PPLiveRoutedEventArgs e) { if (_playLocalFile) { // 接着从上次停止的地方接着观看 LocalPlayFactory localFactory = new LocalPlayFactory(); xPPvodWP7MediaElement.Position = TimeSpan.FromSeconds(localFactory.GetPosition(_localFileId)); return; } _isPlaySucceeded = true; _prepareTime = (DateTime.Now - _programBegin).TotalSeconds; _beginPlaying = DateTime.Now; if (!_mediaIsOpened) { _mediaIsOpened = true; // seek 到以前的位置 if (_openedToSeekPosition > 0) { if (xPPvodWP7MediaElement.CanSeek) { xPPvodWP7MediaElement.Position = TimeSpan.FromSeconds(_openedToSeekPosition); _openedToSeekPosition = 0; } } } }
private void xPPvodWP7MediaElement_MediaEnded(object sender, PPTVWP7MediaPlayer.PPLiveRoutedEventArgs e) { _isPlayEnd = true; _isOver = true; if (_playLocalFile) { // LocalPlayFactory localFactory = new LocalPlayFactory(); localFactory.UpdateRecord(_localFileId, xPPvodWP7MediaElement.Position.Seconds); if (NavigationService.CanGoBack) NavigationService.GoBack(); return; } SaveToDB(ProgramIndex); xPPvodWP7MediaElement.Stop(); _playBufferCount = _allBufferCount - _dragBufferCount; PPTVData.Factory.DACPlayInfo playInfo = new PPTVData.Factory.DACPlayInfo(); playInfo.castType = 3; playInfo.stopReason = 0; playInfo.isPlaySucceeded = _isPlaySucceeded ? 1 : 0; playInfo.connType = _connType; playInfo.dragCount = _dragCount; playInfo.playBufferCount = _playBufferCount; playInfo.dragBufferTime = _dragBufferTime; playInfo.allBufferCount = _allBufferCount; playInfo.bufferTime = _bufferTime; playInfo.prepareTime = _prepareTime; playInfo.programSource = _programSource; playInfo.averageDownSpeed = _averageDownSpeed; playInfo.playTime = _playTime; playInfo.mp4Name = Utils.Utils.UrlDecode(_currentPlayBitrate != null ? _currentPlayBitrate.Rid : ""); PPTVData.Factory.DACFactory.DACPlaying(playInfo, ChannelDetailInfo, Utils.Utils.GetClientVersion()); _isAutoStop = true; PlayNextProgram(); }