예제 #1
0
 private void SetVarDefault()
 {
     _candidacyBitrate   = null;
     _currentPlayBitrate = null;
     _isPlayDBPosition   = true;
     _isPlayEnd          = false;
 }
예제 #2
0
        void playFac_GetPlayInfoSucceed(object sender, HttpFactoryArgs <PlayInfo> args)
        {
            ProgramInfo curProgramInfo = _downProgramInfo[sender as PlayInfoFactory];

            PlayInfo.Item item = args.Result.GetItemByFileType(5);
            if (item == null)
            {
                // _downSign.Visibility = Visibility.Collapsed;
                _downSign.Foreground = new SolidColorBrush(Colors.White);
                if (_piForDownload != null)
                {
                    _piForDownload.IsDown = Visibility.Collapsed;
                }
                string id = string.Empty;

                if (curProgramInfo == null)
                {
                    id = DetailPageHelp.ChannelDetailInfoForPrograms.VID.ToString() + "||";
                }
                else
                {
                    id = DetailPageHelp.ChannelDetailInfoForPrograms.VID + "|" + curProgramInfo.Index + "|" + curProgramInfo.ChannelVID;
                }

                foreach (DownPage.DownInfo info in DownPage.MyDownloading)
                {
                    if (info.VID == id)
                    {
                        DownPage.MyDownloading.Remove(info);
                        break;
                    }
                }
                DownPage.DownFactory.DeleteRecord(id);
                MessageBox.Show("无法下载该文件", "提示", MessageBoxButton.OK);
                return;
            }
            _rid = item.Rid;

            if (item.DtInfo != null)
            {
                _downUrl = item.url;
                if (curProgramInfo == null)
                {
                    DownPage.UpdateTask(DetailPageHelp.ChannelDetailInfoForPrograms.VID.ToString() + "||", _downUrl);
                }
                else
                {
                    DownPage.UpdateTask(DetailPageHelp.ChannelDetailInfoForPrograms.VID + "|" + curProgramInfo.Index + "|" + curProgramInfo.ChannelVID, _downUrl);
                }
            }
            else
            {
                string jump_url = "http://wp7.jump.synacast.com/" + item.Rid + "dt?type=mwp7";
                PPTVData.HttpWebClient jumpWebClient = new PPTVData.HttpWebClient();
                jumpWebClient.DownloadStringCompleted += new PPTVData.DownloadStringCompletedEventHandler(JumpWebClientDownloadStringCompleted);
                jumpWebClient.DownloadStringAsync(jump_url);
            }
        }
예제 #3
0
        protected override PlayInfo AnalysisData(System.Xml.XmlReader reader)
        {
            reader.ReadToFollowing("channel");

            Dictionary <int, PlayInfo.Item> playInfoItems = new Dictionary <int, PlayInfo.Item>();

            while (reader.Read())
            {
                if (reader.Name == "item")
                {
                    if (reader.GetAttribute("bitrate") == null || reader.GetAttribute("ft") == null)
                    {
                        continue;
                    }
                    int           bitrate  = Convert.ToInt32(reader.GetAttribute("bitrate"));
                    int           ft       = Convert.ToInt32(reader.GetAttribute("ft"));
                    string        rid      = reader.GetAttribute("rid");
                    PlayInfo.Item playInfo = new PlayInfo.Item(bitrate, ft, rid, null);
                    playInfoItems.Add(ft, playInfo);
                }

                if (reader.Name == "dt" && reader.NodeType != XmlNodeType.EndElement)
                {
                    int             ft = Convert.ToInt32(reader.GetAttribute("ft"));
                    PlayInfo.DTInfo dt = new PlayInfo.DTInfo();
                    reader.ReadToFollowing("sh");
                    reader.Read();
                    dt.Sh = reader.Value;
                    reader.ReadToFollowing("st");
                    reader.Read();
                    dt.St = reader.Value;
                    reader.ReadToFollowing("bwt");
                    reader.Read();
                    dt.Bwt = Convert.ToInt32(reader.Value);
                    if (playInfoItems.ContainsKey(ft))
                    {
                        playInfoItems[ft].DtInfo = dt;
                    }
                }
            }

            PlayInfo retPlayInfo = new PlayInfo();

            foreach (PlayInfo.Item item in playInfoItems.Values)
            {
                retPlayInfo.Add(item);
            }

            return(retPlayInfo);
        }
예제 #4
0
 /// <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);
 }
예제 #5
0
        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();
            }
        }
예제 #6
0
        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");
        }