MediaElement not playing audio from stream WP7

有些话、适合烂在心里 提交于 2020-01-10 04:24:05

问题


 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 starts.How I can resolve this?


回答1:


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


来源:https://stackoverflow.com/questions/7018335/mediaelement-not-playing-audio-from-stream-wp7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!