Beispiel #1
0
        private async void FileOpenPicker_ContinuationEvent(object sender, Windows.ApplicationModel.Activation.IContinuationActivatedEventArgs e)
        {
            App.ContinuationEventArgsChanged -= FileOpenPicker_ContinuationEvent;

            var arg = e as Windows.ApplicationModel.Activation.FileOpenPickerContinuationEventArgs;

            if (arg != null)
            {
                var file = arg.Files[0];
                if (file != null)
                {
                    SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;
                    if (!kIsPlayRemux)
                    {
                        player.SetSource(await file.OpenReadAsync(), file.ContentType);
                    }
                    else
                    {
                        var plist = new SYEngine.Playlist(SYEngine.PlaylistTypes.LocalFile);
                        plist.Append(file.Path, 0, 0);
                        player.Source = await plist.SaveAndGetFileUriAsync();
                    }
                }
            }
        }
Beispiel #2
0
        private async void PlayLocalVideo()
        {
            List <string> localUrl = new List <string>();

            foreach (var videoFile in _localVideoData.VideoFiles)
            {
                var file = await LocalStorageFunc.GetVideoFileUrl(videoFile);

                if (file != null)
                {
                    localUrl.Add(file);
                }
            }

            var play_list = new SYEngine.Playlist(SYEngine.PlaylistTypes.LocalFile);

            foreach (var url in localUrl)
            {
                play_list.Append(url, 0, 0);
            }

            Player.Source = await play_list.SaveAndGetFileUriAsync();

            Player.Play();
            Player.MediaOpened += Player_MediaOpened;
            Player.MediaEnded  += Player_MediaEnded;
        }
Beispiel #3
0
        private async Task <Uri> GetSource(List <string> play_list)
        {
            Uri source;

            if (play_list.Count == 1 && !syflag)
            {
                source = new Uri(play_list[0]);
            }
            else
            {
                //载入播放引擎
                SYEngine.Core.Initialize();
                var playlist = new SYEngine.Playlist(param.IsLocalFile ? SYEngine.PlaylistTypes.LocalFile : SYEngine.PlaylistTypes.NetworkHttp);
                //将分段添加到playlist
                foreach (var url in play_list)
                {
                    playlist.Append(url, 0, 0);
                }
                //配置引擎
                SYEngine.PlaylistNetworkConfigs cfgs = default(SYEngine.PlaylistNetworkConfigs);
                cfgs.HttpUserAgent          = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36";
                cfgs.HttpReferer            = string.Empty;
                cfgs.HttpCookie             = string.Empty;
                cfgs.UniqueId               = string.Empty;
                cfgs.DownloadRetryOnFail    = true;
                cfgs.DetectDurationForParts = true;
                playlist.NetworkConfigs     = cfgs;
                source = await playlist.SaveAndGetFileUriAsync();
            }
            return(source);
        }
Beispiel #4
0
        private async void btnRemuxPlay_Click(object sender, RoutedEventArgs e)
        {
            tbPlayStatus.Text = string.Empty;
            player.IsLooping  = (bool)cboxLoop.IsChecked;
            SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;

            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 files = await op.PickMultipleFilesAsync();

            if (files != null && files.Count > 0)
            {
                var plist = new SYEngine.Playlist(SYEngine.PlaylistTypes.LocalFile);
                foreach (var file in files)
                {
                    plist.Append(file.Path, 0, 0);
                }
                player.Source = await plist.SaveAndGetFileUriAsync();
            }
        }
Beispiel #5
0
        private async void btnMultiUrl_Click(object sender, RoutedEventArgs e)
        {
            var test = new Uri(tboxNetworkUri.Text);

            var plist = new SYEngine.Playlist(SYEngine.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          = System.IO.Path.GetFileNameWithoutExtension(tboxNetworkUri.Text);
            cfgs.BufferBlockSizeKB = 64;  //one block is 64KB
            cfgs.BufferBlockCount  = 160; //160 * 64K = 10M network io buf.
            plist.NetworkConfigs   = cfgs;
            plist.Append(tboxNetworkUri.Text, 0, 0);
#if DEBUG
            var debugFile = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.TemporaryFolder.Path, "DebugFile.mkv");
            plist.SetDebugFile(debugFile);
#endif

            tbPlayStatus.Text = string.Empty;
            player.IsLooping  = (bool)cboxLoop.IsChecked;
            SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;

            player.Source = await plist.SaveAndGetFileUriAsync();
        }
Beispiel #6
0
        public async void Play2_ClickAsync()
        {
            //https://github.com/amamiya/SYEngine/blob/master/!GUIDE/Segment/Segment.md 播放分段的 FLV\MP4



            //载入播放引擎
            SYEngine.Core.Initialize();
            //所有URL地址列表
            var url_list = new List <String>();//实例化新的 SYEngine.Playlist 对象;

            //url_list.Add("http://data.vod.itc.cn/?rb=1&key=jbZhEJhlqlUN-Wj_HEI8BjaVqKNFvDrn&prod=flash&pt=1&new=/51/116/UdKGIuSjQIO8dynrybyS1E.mp4");


            url_list.Add("http://player.acfun.cn/route_mp4?dt=0&uid=0&timestamp=1540371865&fid=040040020400005BCEED7100010002570000000000-0000-0000-0231-311400000000.mp4&ns=video.acfun.cn&ran=0&vid=5bceeca80cf2c691e00a68fb&customer_id=5859fdaee4b0eaf5dd325b91&sign=ct5bd035990cf22adc685b3ddc");
            //拒绝访问了 问题应该出在请求头


            //构造SYEngine的PlayList。
            var play_list = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);//网络类型

            foreach (var url in url_list)
            {
                //获取每个URL文件的媒体时长和文件大小。
                //如果你的App能通过其他方法提供这些信息,也可以不执行这样的操作。
                // var file = new SYEngine.MediaInformation();
                //await file.OpenAsync(new Uri(url));//失败会有异常,这里忽略。


                play_list.Append(url, 0, 0); // 添加到PlayList
                //也可一〉play_ list. Append(url, D, 0), 然后把cfgs的DetectDur ationF orParts设置为true。
                //播放引擎会自动连接所有 分段地址去获取文件大小和时长。
            }

            //设置网络参数。使用 SYEngine.PlaylistNetworkConfigs 结构体来设置网络参数。这个结构体的相关解释请拉到页面底部的 网络选项说明 来查看
            SYEngine.PlaylistNetworkConfigs cfgs = default(SYEngine.PlaylistNetworkConfigs);
            cfgs.HttpUserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36";

            cfgs.HttpReferer = string.Empty;

            cfgs.HttpCookie = string.Empty;



            cfgs.UniqueId               = string.Empty; //如果要使用动态更新URL,这个不能是Empty,这里不使用。
            cfgs.DownloadRetryOnFail    = true;         //启用断线重连,建议打开。
            cfgs.DetectDurationForParts = true;
            play_list.NetworkConfigs    = cfgs;



            //设置到MedisElement。
            MediaPlayer1.Source = await play_list.SaveAndGetFileUriAsync();// 最后,使用 MediaElement 的 Play 方法来播放,或者设置 AutoPlay 属性为true

            MediaPlayer1.Play();
        }
Beispiel #7
0
        private async void btnMultiFiles_Click(object sender, RoutedEventArgs e)
        {
            var plist = new SYEngine.Playlist(SYEngine.PlaylistTypes.LocalFile);
            plist.Append(Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\MultipartStreamMatroska\\0.mp4", 0, 0);
            plist.Append(Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\MultipartStreamMatroska\\1.mp4", 0, 0);

            tbPlayStatus.Text = string.Empty;
            player.IsLooping = (bool)cboxLoop.IsChecked;
            SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;

            player.Source = await plist.SaveAndGetFileUriAsync();
        }
Beispiel #8
0
        private async void btnMultiFiles_Click(object sender, RoutedEventArgs e)
        {
            var plist = new SYEngine.Playlist(SYEngine.PlaylistTypes.LocalFile);

            plist.Append(Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\MultipartStreamMatroska\\0.mp4", 0, 0);
            plist.Append(Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\MultipartStreamMatroska\\1.mp4", 0, 0);

            tbPlayStatus.Text = string.Empty;
            SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;

            player.Source = await plist.SaveAndGetFileUriAsync();
        }
Beispiel #9
0
        private async void btnMultiUrl_Click(object sender, RoutedEventArgs e)
        {
            var test = new Uri(tboxNetworkUri.Text);

            var plist = new SYEngine.Playlist(SYEngine.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        = System.IO.Path.GetFileNameWithoutExtension(tboxNetworkUri.Text);
            plist.NetworkConfigs = cfgs;
            plist.Append(tboxNetworkUri.Text, 0, 0);

            tbPlayStatus.Text = string.Empty;
            SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;

            player.Source = await plist.SaveAndGetFileUriAsync();
        }
Beispiel #10
0
        private async void PlayVideo(VideosSource vs)
        {
            var play_list = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);

            foreach (var url in vs.AcUrl)
            {
                play_list.Append(url.url, url.size, (float)url.Time);
            }

            SYEngine.PlaylistNetworkConfigs cfgs = default(SYEngine.PlaylistNetworkConfigs);
            cfgs.HttpUserAgent       = "windows 10";
            cfgs.HttpUserAgent       = string.Empty;
            cfgs.HttpReferer         = string.Empty;
            cfgs.HttpCookie          = string.Empty;
            cfgs.UniqueId            = string.Empty;
            cfgs.DownloadRetryOnFail = true;
            play_list.NetworkConfigs = cfgs;
            Player.Source            = await play_list.SaveAndGetFileUriAsync();

            Player.Play();

            Player.MediaOpened += Player_MediaOpened;
            Player.MediaEnded  += Player_MediaEnded;
        }
Beispiel #11
0
        private async void btnRemuxPlay_Click(object sender, RoutedEventArgs e)
        {
            tbPlayStatus.Text = string.Empty;
            player.IsLooping = (bool)cboxLoop.IsChecked;
            SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;

            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(SYEngine.PlaylistTypes.LocalFile);
                plist.Append(file.Path, 0, 0);
                player.Source = await plist.SaveAndGetFileUriAsync();
            }
        }
Beispiel #12
0
        private async void btnMultiUrl_Click(object sender, RoutedEventArgs e)
        {
            var test = new Uri(tboxNetworkUri.Text);

            var plist = new SYEngine.Playlist(SYEngine.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 = System.IO.Path.GetFileNameWithoutExtension(tboxNetworkUri.Text);
            cfgs.BufferBlockSizeKB = 64; //one block is 64KB
            cfgs.BufferBlockCount = 160; //160 * 64K = 10M network io buf.
            plist.NetworkConfigs = cfgs;
            plist.Append(tboxNetworkUri.Text, 0, 0);
#if DEBUG
            var debugFile = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.TemporaryFolder.Path, "DebugFile.mkv");
            plist.SetDebugFile(debugFile);
#endif

            tbPlayStatus.Text = string.Empty;
            player.IsLooping = (bool)cboxLoop.IsChecked;
            SYEngine.Core.ForceSoftwareDecode = (bool)cboxSoftDecode.IsChecked;

            player.Source = await plist.SaveAndGetFileUriAsync();
        }