如何使用 ExpressionMediaPlayer 控件在 Silverlight 中从 Web 服务器流式传输视频?
我想从 ExpressionMediaPlayer 控件中流式传输驻留在网络服务器上的视频。以下结果会导致网络错误。我相信问题出在我的 Uri 上。我的视频位于“ClentBin”文件夹中。谁能告诉我这是怎么做到的?
private void videoList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selectedVideo = (Video)videoList.SelectedItem;
PlaylistItem item = new PlaylistItem();
item.MediaSource = new Uri(@"/ClientBin/" + selectedVideo.FilePath, UriKind.RelativeOrAbsolute);
item.IsAdaptiveStreaming = false;
ep.Playlist.Items.Add(item);
}
谢谢!
I would like to stream videos that reside at the webserver from within a ExpressionMediaPlayer control. The following results in a network error. I believe that the problem is with my Uri. I have the videos inside the 'ClentBin' folder. Can anyone tell me how this is done?
private void videoList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selectedVideo = (Video)videoList.SelectedItem;
PlaylistItem item = new PlaylistItem();
item.MediaSource = new Uri(@"/ClientBin/" + selectedVideo.FilePath, UriKind.RelativeOrAbsolute);
item.IsAdaptiveStreaming = false;
ep.Playlist.Items.Add(item);
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能有多种因素会导致 Expression Media Player 中出现网络错误。以下是一些基本检查...
1。检查视频文件本身
启动 Windows Media Player,转到“文件”>“打开 URL... 并确保您可以使用绝对 URL 播放视频,以排除网络服务器的任何基本问题。 (请注意,如果您正在使用自适应流式处理,则这并不适用,但您似乎并不使用自适应流式处理。)
2.
selectedVideo.FilePath
包含什么?这是一个简单的文件名(即
MyVideo.wmv
)还是一个相对文件路径?正斜杠还是反斜杠?3.尝试使用绝对静态 URI
只是为了排除您的应用程序/网络服务器/任何虚拟目录配置的相对路径问题,请尝试:
4。从 /ClientBin/ 中删除前导斜杠
尝试 new Uri(@"ClientBin/" + selectedVideo.FilePath, UriKind.Relative); 并查看相对路径是否正确。
There can be a number of factors that contribute to a network error in the Expression Media Player. Here are some basic checks...
1. Check the video file itself
Launch Windows Media Player, go to File > Open URL... and make sure you can play the video with the absolute URL, just to rule out any basic problems with the web server. (Note that this does not apply if you are working with Adaptive Streaming, which it doesn't appear you are.)
2. What does
selectedVideo.FilePath
contain?Is this a simple file name (i.e.
MyVideo.wmv
) or is it a relative file path? Forward or backward slashes?3. Try it with an absolute static URI
Just to rule out relative path issues with your app / web server / any virtual directory configuration, try:
4. Remove the leading slash from /ClientBin/
Try just
new Uri(@"ClientBin/" + selectedVideo.FilePath, UriKind.Relative);
and see if the relative path is then correct.