开发者

MediaElement not playing audio from stream WP7

开发者 https://www.devze.com 2023-03-27 11:10 出处:网络
string url = re[\"response\"][0][\"url\"].ToString(); MediaElement mm = new MediaElement(); mm.Source = new Uri(url,UriKind.RelativeOrAbsolute);
 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();

But no changes, the adudio not start开发者_StackOverflows.How I can resolve this?


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消