Windows Phone 7.1 - 媒体元素未播放 [英] Windows Phone 7.1 - Media Element not playing

查看:17
本文介绍了Windows Phone 7.1 - 媒体元素未播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows Phone 7.1/7.5/Mango 应用程序.

Windows Phone 7.1/7.5/Mango app.

我在页面上有四种不同的 MediaElement.

I have four different MediaElements on the page.

  • 加载页面时播放一个.

  • One is played upon Load of the page.

Rest 3 I Play() 它在 leftMouseButtonClick 页面上的不同图像元素上.我在 MediaEnded 事件处理程序中调用 Stop().

Rest 3 I Play() it upon leftMouseButtonClick on different image element on the page. I call Stop() in the MediaEnded event handler.

问题:自上而下顺序中的最后一个 mediaElement 不会播放.因此,行为怪异的不是元素本身而是元素的顺序.

Issue: The last mediaElement in the top-down order won't play. So it's not the element itself bu the order of the element that is behaving weird.

我有阅读此内容 它谈到了我不理解的单个 MediaElement.

I have read this where it talks about a single MediaElement which I don't understand.

有人对此有任何想法吗?

Does anyone has any ideas on this?

注意:我不必同时播放所有声音.一次只有一种声音.

Note: I don't have to play all sound at the same time. Only one sound at a time.

我发现了一个参考文献,它只讨论具有单个 MediaElement 并在代码中动态设置源.我还没有尝试过,很快就会尝试.

I found one reference that talks having single MediaElement only and dynamically set the Source in the code. I haven't tried it yet, will do soon.

推荐答案

为了确认你的最后一句话,每页只能有一个 MediaElement.您必须考虑从代码隐藏(或使用数据绑定)更改源,而不是为每段音频设置 MediaElement.拥有多个 MediaElement 不会引发错误,但它只会覆盖先前添加的行为(就像您遇到的那样).

To confirm your last sentence, you can only have one MediaElement per page. You'll have to consider changing the source from the code-behind (or using data-binding) instead of having a MediaElement for each piece of audio. Having multiple MediaElements won't throw an error, but it will just override the behaviour of the previously added one (like you're experiencing).

要从代码隐藏设置音频,您可以使用 SetSource(接受流)方法,或 Source 读取 Uri 的属性.

To set the audio from the code-behind, you can use either the SetSource (which accepts a stream) method, or the Source property which reads a Uri.

这篇关于Windows Phone 7.1 - 媒体元素未播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆