简体   繁体   English

使用MediaElement在Windows Phone 8上流音频

[英]Stream audio on Windows Phone 8 using MediaElement

I'm trying to stream audio from an online source to a Windows Phone 8 app using MediaElement. 我正在尝试使用MediaElement将音频从在线源流式传输到Windows Phone 8应用程序。

I have the MediaElement in the visual tree and it works with local files but when I try to use files via a URL nothing plays and I get a MediaFailed exception. 我在可视树中有MediaElement,它可与本地文件一起使用,但是当我尝试通过URL使用文件时,没有任何反应,并且出现了MediaFailed异常。 The media failed error has the code 3100. It neither worked with AAC or MP3 but worked with video. 媒体失败错误代码为3100。它既不适用于AAC或MP3,也不适用于视频。

My code: 我的代码:

sound.Source = new Uri(url, UriKind.RelativeOrAbsolute);
      sound.MediaFailed += sound_MediaFailed;
      sound.AutoPlay = true;

Maybe it isn't possible to do it this way, but if anyone could help it'd be appreciated. 也许不可能以这种方式做到这一点,但是如果有人可以帮助的话,我们将不胜感激。

UPDATE: 更新:

The file I've tried to use is http://rapidshare.com/files/2276097672/firework.aac . 我尝试使用的文件是http://rapidshare.com/files/2276097672/firework.aac This file works locally on the phone but not online. 此文件在手机上本地工作,但不在网上工作。 Maybe I've misunderstood and I can't stream directly from this web location. 也许我误会了,因此无法直接从此网站流式传输。

The file was inaccessible. 该文件不可访问。 Not really an answer as it's a stupid mistake but the problem has been solved. 这不是一个真正的答案,因为它是一个愚蠢的错误,但问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM