void BeginGetInfoNPlay(bool isPlayOtherProgram = false, bool isPlayNextProgram = true) { if (isPlayOtherProgram) { if (ChannelDetailInfo != null) { if (isPlayNextProgram) { //下一集 int temp = ProgramIndex + 1; if (temp < ChannelDetailInfo.ProgramInfos.Count) { //有下一集时, 1.保存当集 2.播放下一集 _currentPlayBitrate = null; SetInfo(true, "正在加载第" + ChannelDetailInfo.ProgramInfos[temp].Title + "集"); SetControlBarStatus(false, true); ProgramIndex = temp; SaveToDB(temp - 1); } else { if (NavigationService.CanGoBack) NavigationService.GoBack(); } } else { //上一集 int temp = ProgramIndex - 1; if (temp >= 0) { //有上一集时, 1.保存当集 2.播放上一集 _currentPlayBitrate = null; SetInfo(true, "正在加载第" + ChannelDetailInfo.ProgramInfos[temp].Title + "集"); SetControlBarStatus(false, true); ProgramIndex = temp; SaveToDB(temp + 1); } } } else { //_isPlayProgram = true; //_isPlayNextProgram = true; } } if (ChannelDetailInfo == null) { //重新读取影片信息 SetControlBarStatus(false, true); SetInfo(true, "正在读取影片信息"); _channelDetailFactory.DownLoadDatas(VID); } else if (_currentPlayBitrate == null || string.IsNullOrEmpty(_currentPlayBitrate.Rid) || _currentPlayBitrate.Rid == "null") { //只读Play接口信息 StartGetPlayAPI(); } }
protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e) { _timer.Stop(); _timerOfControlBar.Stop(); if (_playLocalFile) { xPPvodWP7MediaElement.Pause(); if (xPPvodWP7MediaElement.CurrentState == MediaElementState.Paused || xPPvodWP7MediaElement.CurrentState == MediaElementState.Playing) {// 更新当前的播放位置 LocalPlayFactory localFacotry = new LocalPlayFactory(); localFacotry.UpdateRecord(_localFileId, (long)xPPvodWP7MediaElement.Position.TotalSeconds); } return; } LogManager.Ins.Log("开始退出执行DAC"); if (xPPvodWP7MediaElement.CurrentState != MediaElementState.Stopped) { _playTime = (DateTime.Now - _beginPlaying).TotalSeconds; _playBufferCount = _allBufferCount - _dragBufferCount; PPTVData.Factory.DACPlayInfo playInfo = new PPTVData.Factory.DACPlayInfo(); playInfo.castType = 3; playInfo.stopReason = 1; playInfo.isPlaySucceeded = _isPlaySucceeded ? 1 : 0; LogManager.Ins.Log("查Wifi开始"); playInfo.connType = _connType; LogManager.Ins.Log("查Wifi结束"); 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 : ""); if (ChannelDetailInfo != null && !_isAutoStop) PPTVData.Factory.DACFactory.DACPlaying(playInfo, ChannelDetailInfo, Utils.Utils.GetClientVersion()); _isAutoStop = false; } LogManager.Ins.Log("DAC完成"); SetInfo(true); LogManager.Ins.Log("开始保存到数据库"); if (xPPvodWP7MediaElement.CurrentState == MediaElementState.Paused || xPPvodWP7MediaElement.CurrentState == MediaElementState.Playing) SaveToDB(ProgramIndex); LogManager.Ins.Log("数据库保存完成"); //if (_isBackPress) // xPPvodWP7MediaElement.OriSource = ""; ChannelDetailInfo = null; _currentPlayBitrate = null; LogManager.Ins.Log("清空Source"); }
/// <summary> /// 播放候选码流率的第一个 /// </summary> /// <param name="keepCurrentPosition">是否保存当前的播放位置</param> /// <returns>false 播放失败,已经没有码流率可供选择了</returns> bool PlayFirstCondidacyBitrate(bool keepCurrentPosition) { if (_candidacyBitrate.Count <= 0) { return false; } while (_candidacyBitrate.Count > 0) { int bitrate = _candidacyBitrate.First(); _candidacyBitrate.RemoveAt(0); PlayInfo.Item item = _playInfo.GetItemByFileType(bitrate); if (item != null) { if (keepCurrentPosition) { if (_mediaIsOpened) { _openedToSeekPosition = xPPvodWP7MediaElement.Position.TotalSeconds; } } else { _openedToSeekPosition = 0; } if (item.DtInfo != null) { xPPvodWP7MediaElement.DirectSource = item; } else if (!string.IsNullOrEmpty(item.Rid) && item.Rid != "null") { xPPvodWP7MediaElement.OriSource = item; } _mediaIsOpened = false; _currentPlayBitrate = item; HighlightCurentBitrate(); return true; } } return false; }
private void SetVarDefault() { _candidacyBitrate = null; _currentPlayBitrate = null; _isPlayDBPosition = true; _isPlayEnd = false; }