Exemplo n.º 1
0
    public async static Task<VideoPlayInfo> getMobileVideoInfo(string vid)
    {
        VideoPlayInfo playInfo = new VideoPlayInfo();

        //请求并获取返回的json串,截取符合json解析公共方法的部分。
        string str_json = await GetOpen56APi("http://oapi.56.com/video/mobile.json", "vid=" + vid);

        if (string.IsNullOrEmpty(str_json))
            return null;

        int begin = str_json.IndexOf(":{");
        int end = str_json.LastIndexOf("},");
        str_json = str_json.Substring(begin + 1, (end - begin));

        //调用Json解析公共方法,将Json串转化成List<WebsiteCategory>
        playInfo = JsonUtil.Deserialize<VideoPlayInfo>(str_json);
        return playInfo;
    }
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            listToPlayParam = (ListToPlayParam)e.Parameter;
            AllVidellist = listToPlayParam.AllVidellist;
            CurMediaInfo = listToPlayParam.PlayInfo;
            CurMediaIndex = listToPlayParam.AllVidellist.FindIndex(info => info.Vid == listToPlayParam.PlayInfo.vid);

            if (DisplayInformation.GetForCurrentView().CurrentOrientation != DisplayOrientations.Landscape)
            {
                DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
            }

            HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            StartLoadVideo(listToPlayParam.PlayInfo);
        }
        private void StartLoadVideo(VideoPlayInfo PlayInfo)
        {
            CurMediaIndex = listToPlayParam.AllVidellist.FindIndex(info => info.Vid == PlayInfo.vid);
            CurMediaInfo = PlayInfo;
            mediaPlayControl.MediaTitle = PlayInfo.Subject;

            //不支持高清
            if (PlayInfo.rfiles[3].filesize == null)
            {
                mediaPlayControl.IsSupportHD = false;

                movieparam param = PlayInfo.rfiles[2];
                mediaPlayControl.ResolutionIndex = 2;
                mediaPlayControl.MediaSource = new Uri(param.url);
            }
            else
            {
                mediaPlayControl.IsSupportHD = true;
                movieparam param = PlayInfo.rfiles[CurrentResolutionIndex];
                mediaPlayControl.ResolutionIndex = CurrentResolutionIndex;
                mediaPlayControl.MediaSource = new Uri(param.url);
            }
        }