コード例 #1
0
        private async void Button_Click_Play(object sender, RoutedEventArgs e)
        {
            var    sendBtn = sender as Button;
            string playUrl = sendBtn.CommandParameter.ToString();

            if (!string.IsNullOrEmpty(gMediaId))
            {
                await ReUserActionDataSource.SetUserAction(gMediaId);
            }

            if (!String.IsNullOrEmpty(playUrl))
            {
                string tempPlayUrl      = playUrl;
                String specialUrlStarts = "baidu://";
                String specialUrlEnds   = ".m3u8";

                Random random = new Random();
                int    r      = random.Next();

                // for download resource
                if (tempPlayUrl.StartsWith(specialUrlStarts, StringComparison.OrdinalIgnoreCase))
                {
                    String switchUrl = "http://replatform.cloudapp.net:8000/getplay?id={0}&v={1}&uuid={2}&type={3}&from={4}&to={5}&r={6}";
                    playUrl = String.Format(switchUrl, gMediaId, tempPlayUrl, App.gDeviceName, App.gDeviceType, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo(), r);

                    string realUrl = await ReDetailDataSource.GetHLSPlayUrlAsync(playUrl);

                    playUrl = realUrl;
                }
                // for .m3u8 resource
                // in the future maybe play the media in my app
                else if (tempPlayUrl.EndsWith(specialUrlEnds, StringComparison.OrdinalIgnoreCase))
                {
                    String switchUrl = "http://replatform.cloudapp.net:8000/getplay?id={0}&v={1}&uuid={2}&type={3}&from={4}&to={5}&r={6}";
                    playUrl = String.Format(switchUrl, gMediaId, tempPlayUrl, App.gDeviceName, App.gDeviceType, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo(), r);

                    string realUrl = await ReDetailDataSource.GetHLSPlayUrlAsync(playUrl);

                    playUrl = realUrl;
                }

                // Create the URI to launch from a string.
                Uri resourceUri;
                if (!Uri.TryCreate(playUrl.Trim(), UriKind.Absolute, out resourceUri))
                {
                    return;
                }
                // Launch the URI.
                LaunchIE(resourceUri);
            }
        }
コード例 #2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            gMediaId = e.NavigationParameter as string;
            var group = await ReDetailDataSource.GetWebServiceDetailAsync(gMediaId);

            if (group == null)
            {
                Helpers.InternetFailureAlarm();
            }
            else
            {
                this.DefaultViewModel["Group"] = group;
                this.DefaultViewModel["Items"] = group.Items;
            }
        }