【发布时间】:2016-04-28 18:03:20
【问题描述】:
我有可以播放 .m3u8 文件的应用程序。
但是,当视频使用MPEG 1/2 (mpgv) 编码时,它只显示空白屏幕。打开H.264 之类的视频时,一切正常。怎么了?
代码如下:
using Microsoft.Media.AdaptiveStreaming;
//Listing: MainPage.xaml.cs -> class
private MediaExtensionManager extensions;
private PropertySet propertySet;
private IAdaptiveSourceManager adaptiveSourceManager;
//Listing: MainPage.xaml.cs -> class -> constructor
propertySet = new PropertySet();
extensions = new MediaExtensionManager();
adaptiveSourceManager = AdaptiveSourceManager.GetDefault();
propertySet["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = adaptiveSourceManager;
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", propertySet);
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", propertySet);
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/x-mpegurl", propertySet);
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "video/mp2t", propertySet);
extensions.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", propertySet);
//Listing -> MainPage.xaml.cs -> OnNavigatedTo method
//Getting manifest.m3u8
var link = new Uri("path_to_remote_m3u8_file");
Player.Source = link;
Player.Play();
//Listing: MainPage.xaml
<MediaElement x:Name="Player" />
通常,在.m3u8 中,我们有.ts 文件的列表。但是H.264编码的可以播放,MPEG-1或MPEG-2编码的不能播放。
我想我需要向extensions 添加更多处理程序,或者我应该向Microsoft Player Framework 添加更多处理程序,但它们没有适用于 Windows 10 的Dash plugin,因此按照this 示例我无法完成结果。或者可能是 FFmpeg?
【问题讨论】:
标签: c# windows-store-apps win-universal-app m3u8