为什么 MediaElement 不能在 Silverlight 中工作?

发布于 2024-07-12 19:39:24 字数 322 浏览 9 评论 0原文

当我运行 Silverlight 应用程序时,此代码根本不播放视频:

    <MediaElement
        Source="winvideo-201DataGridPreview.wmv"
        AutoPlay="True"
        AudioStreamIndex="2"
        Margin="10"
        Height="200"
        Width="200"/>

从我能找到的 MediaElement 的所有示例来看,它似乎是正确的语法等。

有什么我忘记的吗?

When I run my Silverlight app, this code doesn't play a video at all:

    <MediaElement
        Source="winvideo-201DataGridPreview.wmv"
        AutoPlay="True"
        AudioStreamIndex="2"
        Margin="10"
        Height="200"
        Width="200"/>

From all of the examples I can find of MediaElement, it seems to be the correct syntax, etc.

Is there anything I'm forgetting?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

伴我老 2024-07-19 19:39:33

这非常烦人,但发现如果您右键单击媒体文件和属性并将其设置为“内容”构建操作,它将包含在 XAP 中,然后您可以使用 /myPic.jpg/wmv 或 /Images/myPic 引用它.jpg/wmv(显然取决于您的项目和视频或图片的结构)。 希望这可以帮助

This was very annoying but found that if you right click on your media file and properties and set it to "Content" build action it will be included in the XAP, then you reference it with /myPic.jpg/wmv or /Images/myPic.jpg/wmv (depending on the structure of your project and vid or pic obviously). Hope this helps

够钟 2024-07-19 19:39:31

我遇到了同样的问题,我还没有找到可以正确引用视频文件的正确配置。 如果我通过源“vid1.wmv”引用我的视频并将其设置为内容,它会打包到 xap 文件中,但视频不会播放。

正如 TimHeuer 所说,检查视频文件与 .xap 文件位于同一位置。

如果我将视频文件直接复制到网络项目的ClientBin中,它就可以工作。
这对我来说是解决方案,但我真的很想知道应该如何正确完成此操作。

I'm getting the same issue, I haven't found the right configuration that will reference the video file correctly. If I reference my video by source "vid1.wmv" and set it to content, it's packaged into the xap file but the video won't play.

As TimHeuer says, check the video file is in the same place as the .xap file.

If I copy the video file directly into the web project's ClientBin, it works.
That was the solution for me, but I'd really like to know how this should be done correctly.

此岸叶落 2024-07-19 19:39:30

这可能是媒体文件不受支持的情况。

这些是受支持的(来源:http://msdn.microsoft .com/en-us/library/cc189080(VS.95).aspx)

MediaElement 对象支持以下格式。 无论文件扩展名如何,都支持这些编码。

视频

  • WMV1:Windows Media Video 7
  • WMV2:Windows Media Video 8
  • WMV3:Windows Media Video 9
  • WMVA:Windows Media Video 高级
  • 配置文件,非 VC-1
  • WMVC1:Windows Media Video Advanced
    配置文件,VC-1

音频

  • WMA 7:Windows Media Audio 7

  • WMA 8:Windows Media Audio 8

  • WMA 9:Windows Media 音频 9

  • WMA 10:Windows Media 音频 10

  • MP3:ISO/MPEG Layer-3

    • 输入:ISO/MPEG Layer-3 数据流

    • 通道配置:单声道、立体声

    • 采样频率:8、11.025、12、16、22.05、24、32、44.1 和 48 kHz

    • 比特率:8-320 kbps,可变比特率

    • 限制:不支持“自由格式模式”(请参阅​​ ISO/IEC 11172-3,子条款 2.4.2.3)。

测试视频文件是否与 Silverlight 兼容的非常简单(但有点暴力)的方法是将其上传到 http: //Silverlight Streaming 它会告诉你是否可以。

It might be the case of unsupported mediafile.

These are supported (source: http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx)

The MediaElement object supports the following formats. These encodings are supported regardless of the file name extension.

Video

  • WMV1: Windows Media Video 7
  • WMV2: Windows Media Video 8
  • WMV3: Windows Media Video 9
  • WMVA: Windows Media Video Advanced
  • Profile, non-VC-1
  • WMVC1: Windows Media Video Advanced
    Profile, VC-1

Audio

  • WMA 7: Windows Media Audio 7

  • WMA 8: Windows Media Audio 8

  • WMA 9: Windows Media Audio 9

  • WMA 10: Windows Media Audio 10

  • MP3: ISO/MPEG Layer-3

    • Input: ISO/MPEG Layer-3 data stream

    • Channel configurations: mono, stereo

    • Sampling frequencies: 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, and 48 kHz

    • Bit rates: 8-320 kbps, variable bit rate

    • Limitations: "free format mode" (see ISO/IEC 11172-3, sub clause 2.4.2.3) is not supported.

On really simple (but a bit brute force) way to test if your video file is Silverlight compatible is to upload it to http://Silverlight streaming and it will tell you if it is ok or not.

独木成林 2024-07-19 19:39:29

Edward,根据您的 XAML 检查:1)WMV 文件采用适当的编码格式,2)WMV 文件位于 XAP 文件所在的位置旁边(我实际上会先检查这一点)。

Edward, based on your XAML check: 1) that the WMV file is in the appropriate encoding format, 2) that the WMV file is located alongside where your XAP file is (I'd actually check this first).

始终不够 2024-07-19 19:39:27

引用的媒体文件需要位于 ClientBin 文件夹中。 对于 Sliver-light 4.0,您不仅可以使用 .wmv 格式,还可以使用 .mp4 格式。

The referenced media files need to be in ClientBin folder. For Sliver-light 4.0 you may use not only .wmv but .mp4 format as well.

并安 2024-07-19 19:39:27

我有类似的问题。 我将 wmv 文件作为现有对象添加到我的 Silverlight 项目中,然后在 wmv 文件的属性上,将其构建操作设置为 Resource。 一旦我这样做了,它就会为我播放。

I had a similar problem. I added the wmv file as an existing object to my Silverlight project, and then on the properties of the wmv file, I set its build action to Resource. Once I did this it would play for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文