Exemple #1
0
        private async void MultiUrlBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var url = NetworkUrlTextBox.Text;

            if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri))
            {
                await new MessageDialog("Not a valid uri format.", "Error").ShowAsync();
                return;
            }

            var plist = new SYEngine.Playlist(PlaylistTypes.NetworkHttp);
            var cfgs  = default(SYEngine.PlaylistNetworkConfigs);

            cfgs.DownloadRetryOnFail    = true;
            cfgs.DetectDurationForParts = true;
            cfgs.HttpUserAgent          = string.Empty;
            cfgs.HttpReferer            = string.Empty;
            cfgs.HttpCookie             = string.Empty;
            cfgs.UniqueId          = Path.GetFileNameWithoutExtension(NetworkUrlTextBox.Text);
            cfgs.BufferBlockSizeKB = 64;  //one block is 64KB
            cfgs.BufferBlockCount  = 160; //160 * 64K = 10M network io buf.
            plist.NetworkConfigs   = cfgs;
            plist.Append(NetworkUrlTextBox.Text, 0, 0);
#if DEBUG
            var debugFile = Path.Combine(Windows.Storage.ApplicationData.Current.TemporaryFolder.Path, "DebugFile.mkv");
            plist.SetDebugFile(debugFile);
#endif

            PlayStatusBlock.Text = string.Empty;
            Player.Source        = await plist.SaveAndGetFileUriAsync();
        }
Exemple #2
0
        public static async Task <ReturnPlayModel> Get23MoeUrl(PlayerModel model, int qn)
        {
            try
            {
                var           playList = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);
                List <string> urls     = new List <string>();
                string        rnd      = ApiHelper.GetTimeSpan.ToString();
                if (SettingHelper.Get_UseVIP())
                {
                    rnd = "true" + rnd;
                }
                var re3 = await WebClientClass.GetResults(new Uri(string.Format("https://moe.nsapps.cn/api/v1/BiliAnimeUrl?animeid={0}&cid={1}&epid={2}&rnd={3}", model.banId, model.Mid, model.banInfo.episode_id, rnd)));

                JObject obj = JObject.Parse(re3);
                if (Convert.ToInt32(obj["code"].ToString()) == 0)
                {
                    if (obj["mode"].ToString() == "mp4")
                    {
                        urls.Add(obj["data"][0]["url"].ToString());
                        return(new ReturnPlayModel()
                        {
                            usePlayMode = UsePlayMode.System,
                            url = obj["data"][0]["url"].ToString(),
                            urls = urls,
                            from = "server"
                        });
                    }
                    else
                    {
                        var returnPlayModel = new ReturnPlayModel()
                        {
                            usePlayMode = UsePlayMode.SYEngine,
                            from        = "server"
                        };
                        foreach (var item in obj["data"])
                        {
                            playList.Append(item["url"].ToString(), item["size"].ToInt32(), item["length"].ToInt32() / 1000);
                            urls.Add(item["url"].ToString());
                        }
                        playList.NetworkConfigs  = CreatePlaylistNetworkConfigs("https://www.bilibili.com/bangumi/play/ep" + model.episode_id);
                        returnPlayModel.playlist = playList;
                        returnPlayModel.urls     = urls;
                        return(returnPlayModel);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemple #3
0
        private async void MultiFilesBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var installPath = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
            var plist       = new SYEngine.Playlist(PlaylistTypes.LocalFile);

            plist.Append(installPath + "\\Assets\\MultipartStreamMatroska\\0.mp4", 0, 0);
            plist.Append(installPath + "\\Assets\\MultipartStreamMatroska\\1.mp4", 0, 0);

            PlayStatusBlock.Text = string.Empty;
            Player.Source        = await plist.SaveAndGetFileUriAsync();
        }
Exemple #4
0
        private async void RemuxPlayBtn_OnClick(object sender, RoutedEventArgs e)
        {
            PlayStatusBlock.Text = string.Empty;

            var op = new FileOpenPicker();

            op.ViewMode = PickerViewMode.List;
            op.FileTypeFilter.Add(".flv");
            op.FileTypeFilter.Add(".f4v");
            op.FileTypeFilter.Add(".mkv");
            op.FileTypeFilter.Add(".mp4");
            var file = await op.PickSingleFileAsync();

            if (file != null)
            {
                var plist = new SYEngine.Playlist(PlaylistTypes.LocalFile);
                plist.Append(file.Path, 0, 0);
                Player.Source = await plist.SaveAndGetFileUriAsync();
            }
        }
Exemple #5
0
        public static async Task <ReturnPlayModel> GetBilibiliBangumiUrl(PlayerModel model, int qn)
        {
            try
            {
                List <string> urls     = new List <string>();
                var           playList = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);
                string        url2     = string.Format(
                    "https://bangumi.bilibili.com/player/web_api/v2/playurl?cid={1}&appkey={0}&otype=json&type=&quality={2}&module=bangumi&season_type=1&qn={2}&ts={3}", ApiHelper._appKey_VIDEO, model.Mid, qn, ApiHelper.GetTimeSpan_2);
                url2 += "&sign=" + ApiHelper.GetSign_VIDEO(url2);
                var re = await WebClientClass.GetResultsUTF8Encode(new Uri(url2));

                FlvPlyaerUrlModel m = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                //是否遇到了地区限制
                if (m.code == 0 && !re.Contains("8986943"))
                {
                    foreach (var item in m.durl)
                    {
                        urls.Add(item.url);
                        playList.Append(item.url, item.size, item.length / 1000);
                    }
                    playList.NetworkConfigs = CreatePlaylistNetworkConfigs("https://www.bilibili.com/bangumi/play/ep" + model.episode_id);
                    return(new ReturnPlayModel()
                    {
                        playlist = playList,
                        usePlayMode = UsePlayMode.SYEngine,
                        urls = urls,
                        from = "bilibili"
                    });
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemple #6
0
        /// <summary>
        /// 读取视频播放地址
        /// </summary>
        /// <param name="model"></param>
        /// <param name="quality"></param>
        /// <returns></returns>
        public static async Task <ReturnPlayModel> GetVideoUrl(string aid, string cid, int qn)
        {
            try
            {
                if (qn < 10)
                {
                    switch (qn)
                    {
                    case 1:
                        qn = 32;
                        break;

                    case 2:
                        qn = 64;
                        break;

                    case 3:
                        qn = 80;
                        break;

                    case 4:
                        qn = 116;
                        break;

                    default:
                        qn = 64;
                        break;
                    }
                }
                List <string> urls = new List <string>();
                string        url  = $"https://api.bilibili.com/x/player/playurl?avid={aid}&cid={cid}&qn={qn}&type=&otype=json&appkey={ApiHelper._appKey_VIDEO}";
                url += "&sign=" + ApiHelper.GetSign_VIDEO(url);
                string re = await WebClientClass.GetResults(new Uri(url));

                FlvPlyaerUrlModel m = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                if (m.code == 0)
                {
                    var playList = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);
                    foreach (var item in m.data.durl)
                    {
                        urls.Add(item.url);
                        playList.Append(item.url, item.size, item.length / 1000);
                    }
                    playList.NetworkConfigs = CreatePlaylistNetworkConfigs("https://www.bilibili.com/video/av" + aid + "/");

                    return(new ReturnPlayModel()
                    {
                        usePlayMode = UsePlayMode.SYEngine,
                        playlist = playList,
                        urls = urls,
                        from = "bilibili"
                    });
                }
                var biliplus = await GetBiliPlusUrl(cid, qn, "https://www.bilibili.com/video/av" + aid + "/");

                if (biliplus != null)
                {
                    return(biliplus);
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemple #7
0
        /// <summary>
        /// 使用biliplus的接口,支持番剧/视频
        /// 需要授权
        /// </summary>
        /// <param name="model"></param>
        /// <param name="qn"></param>
        /// <returns></returns>
        public static async Task <ReturnPlayModel> GetBiliPlusUrl(string cid, int qn, string referer)
        {
            try
            {
                string url = "https://www.biliplus.com/BPplayurl.php?cid=" + cid + $"&otype=json&type=&quality={qn}&module=bangumi&season_type=1&qn={qn}&access_key={ApiHelper.access_key}";
                Dictionary <string, string> header = new Dictionary <string, string>();
                if (SettingHelper.Get_BiliplusCookie() != "")
                {
                    header.Add("Cookie", SettingHelper.Get_BiliplusCookie());
                }

                string re = await WebClientClass.GetResults(new Uri(url));

                FlvPlyaerUrlModel m = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                if (m.code == 0)
                {
                    List <string> urls     = new List <string>();
                    var           playList = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);
                    foreach (var item in m.durl)
                    {
                        urls.Add(item.url);
                        playList.Append(item.url, item.size, item.length / 1000);
                    }
                    playList.NetworkConfigs = CreatePlaylistNetworkConfigs(referer);
                    return(new ReturnPlayModel()
                    {
                        playlist = playList,
                        usePlayMode = UsePlayMode.SYEngine,
                        urls = urls,
                        from = "biliplus"
                    });
                }
                else if (m.code == -403)
                {
                    if (ApiHelper.IsLogin())
                    {
                        ReturnPlayModel returnPlayModel = null;
                        MessageDialog   messageDialog   = new MessageDialog("读取视频地址失败了,是否授权Biliplus后再试一次?");
                        messageDialog.Commands.Add(new UICommand("授权", async(e) => {
                            var bp = await Account.AuthBiliPlus();
                            if (bp != "")
                            {
                                returnPlayModel = await GetBiliPlusUrl(cid, qn, referer);
                            }
                            else
                            {
                                Utils.ShowMessageToast("授权失败了");
                            }
                        }));
                        messageDialog.Commands.Add(new UICommand("取消"));
                        await messageDialog.ShowAsync();

                        return(returnPlayModel);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }