MediaElement无法播放来自流WP7的音频 [英] MediaElement not playing audio from stream WP7

查看:116
本文介绍了MediaElement无法播放来自流WP7的音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 string url = re["response"][0]["url"].ToString();
 MediaElement mm = new MediaElement();
 mm.Source = new Uri(url,UriKind.RelativeOrAbsolute);
 mm.AutoPlay = true;
 mm.Volume = 0.7;
 mm.Play();

但是没有任何变化,adudio无法启动.我该如何解决?

But no changes, the adudio not starts.How I can resolve this?

推荐答案

您需要在播放MediaTree之前将其添加到VisualTree中,因为您是在背后的代码中创建它的.例如,假设您有LayoutRoot并且您的url是正确的,那么这应该可以工作.

You need to add your MediaElement to your VisualTree before playing it, since you're creating it in the codebehind. For example, assuming you have LayoutRoot and that your url is correct, this should work.

string url = re["response"][0]["url"].ToString();
MediaElement mm = new MediaElement();
mm.Source = new Uri(url,UriKind.RelativeOrAbsolute);
mm.AutoPlay = true;
mm.Volume = 0.7;
LayoutRoot.Children.Add(mm);
mm.Play();

这篇关于MediaElement无法播放来自流WP7的音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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