MediaElement not playing audio from stream WP7

前端 未结 1 470
Happy的楠姐
Happy的楠姐 2020-12-19 23:51
 string url = re[\"response\"][0][\"url\"].ToString();
 MediaElement mm = new MediaElement();
 mm.Source = new Uri(url,UriKind.RelativeOrAbsolute);
 mm.AutoPlay = tr         


        
1条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-20 00:20

    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 讨论(0)
提交回复
热议问题