none
Problems loading server-side http stream in MediaElement

    Question

  • Hey,

     

    I have a problem playing a server-side stream in a MediaElement. I use the Silverlight 2 Beta 2 framework.

     

    My Silverlight code is as follows:

    <UserControl x:Class="MySilverlightSite.Controls.MusicPlayer"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="500" Height="30" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

    <Grid>

    <MediaElement IsMuted="False" x:Name="_MePlayMusic" Margin="0,0,0,0" Source="http://MYIPADDRESS:PORTNUMBER/" />

    </Grid>

    </UserControl>

     

    I get the following error message when trying to run the code: 4001 AG_E_NETWORK_ERROR. When I take the address to the stream (here in the code: http://MYIPADDRESS:PORTNUMBER/) I would like to play and open it in Windows Media Player it opens perfectly so the address should be correct.

     

    I have tried to search this forum and google the error and couldn't find any solution to it. Hope any one on this forum have a solution to my problem.

     

    Thanks in advance.

    • Moved by Pete Brown Thursday, July 24, 2008 11:16 AM Migration data
    Wednesday, July 23, 2008 10:02 AM

Answers

  • I solved the problem! Smile It all work perfectly now! It turned out that the MediaElement couldn't load the stream in Mp3-format (I think it was in Mp3PRO-format). When using an WMA-stream it worked...

    Thanks to all for your help!

    Friday, August 01, 2008 6:54 AM

All replies

  • Hello, have you encoded the file with Expression Encoder? Also make sure you're running your Silverlight application from the http protocol, not the local file system.

    Friday, July 25, 2008 3:43 AM
  • Hello, have you encoded the file with Expression Encoder? Also make sure you're running your Silverlight application from the http protocol, not the local file system.

     

    Hey Yi-Lun,

    Thanks for your reply.

    It's not a file, but a live server-side http stream from a ShoutCast radio station so no I have not encoded it in Expression Encoder. I run the Silverlight application locally when developing it. Is that causing a problem?

    Friday, July 25, 2008 4:39 AM
  • Make sure the stream returns VC-1 encoded contents (wmv). That's the only format supported by Silverlight.

    Friday, July 25, 2008 5:06 AM
  • Make sure the stream returns VC-1 encoded contents (wmv). That's the only format supported by Silverlight.

     

    But it's not a video stream. It's an audio stream sent in Mp3-encoding. Why are you talking video?

    Friday, July 25, 2008 5:29 AM
  • Not all mp3 is supported. Please refer to http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx.

    Friday, July 25, 2008 5:43 AM
  • Not all mp3 is supported. Please refer to http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx.

    I have studied that page several times and the Mp3-stream should be supported. The stream is encoded as: MPEG Audio Layer-3 160Kbps Stereo. So that should not be a problem...

    Friday, July 25, 2008 5:52 AM
  •  I've successfully loaded Shoutcast streams with SL2...

    You can read about it here... feel free to ask any questions in the comments

    Things to remember:

    Replace http:// with mms:// for the url of the stream

    If the stream is the root of the server, follow it with a semi colon

    so, http://shoutcastserver.net:8000/ would become mms://shoutcastserver.net:8000/;

    Also, unless published online or on a local webserver, this will not work.

    Sunday, July 27, 2008 7:32 PM
  •  I've successfully loaded Shoutcast streams with SL2...

    You can read about it here... feel free to ask any questions in the comments

    Things to remember:

    Replace http:// with mms:// for the url of the stream

    If the stream is the root of the server, follow it with a semi colon

    so, http://shoutcastserver.net:8000/ would become mms://shoutcastserver.net:8000/;

    Also, unless published online or on a local webserver, this will not work.

     

    Thanks spender for your post. I've read 2 of your blogs with streaming and it was very interesting.

    I've tried the "tricks" you wrote and now I don't get any errors when playing the stream but I don't get any sound either Sad

    What can I do about that?

    I run the xaml from my local machine. Will it work if I run it on a webserver?

    Monday, July 28, 2008 7:32 AM
  •  From my own experience, yes, it will run if you put the content on a webserver. When running in the local security zone, something goes wrong. If it is anything like Flash (I'm a bit of a Silverlight noob), mixing local and online file access is not allowed.

    Monday, July 28, 2008 7:36 AM
  •  From my own experience, yes, it will run if you put the content on a webserver. When running in the local security zone, something goes wrong. If it is anything like Flash (I'm a bit of a Silverlight noob), mixing local and online file access is not allowed.

     

    Thanks for your quick response!

    Something weird happened when I tried the things you wrote. First i tried with mms-stream and I got no error and no sound. Then I tried with Http and got a millisecond of sound and then it stopped. I tried to switch back to mms and now with both that and http i get the same error as I got in the beginning...

    I'll try a webserver...

    Monday, July 28, 2008 7:41 AM
  •  let me know how you get on... if you can get it working too, I'll make a more detailed post on our blog.

     

    thanks.

    Monday, July 28, 2008 7:45 AM
  •  let me know how you get on... if you can get it working too, I'll make a more detailed post on our blog.

    thanks.

     

    I'll do so if i get it up and running... Smile

    Monday, July 28, 2008 7:51 AM
  • Okay I got an idea when trying today to get it running on the developing laptop... AND I GOT IT STREAMING! Cool

    I did the following:

    1. I made a status TextBlock where I print out messages about the stream.
    2. I set the source of the MediaElement in code-behind like this (note that I a have used the tricks from spender): _MePlayMusic.Source = new Uri("mms://IPADDRESS:PORTNUMBER/;", UriKind.Absolute);
    3. Use the CurrentStateEvent on the MediaElement to print out the state that the MediaElement is in to find out what it's doing (with a switch statement and the previously mentioned TextBlock).
    4. Change the BufferingTime of the MediaElement to 10 or 20 seconds.

    ... and out of the blue it started streaming from the server.... Big Smile It doesn't start streaming every time I open it and when it doesn't start it has a state of "Paused" (I didn't think that was possible with a server-side stream and Silverlight but nevermind...)

    My idea, without having tried it, the problem is that it's not run from a webserver. I have the security settings in Vista accused of giving me the problems opening the stream...

    Tuesday, July 29, 2008 8:23 AM
  • great news... glad i could help

    Tuesday, July 29, 2008 8:39 AM
  • great news... glad i could help

     

    Thanks for your help! I had never figured out the tricks you wrote about myself. Hope you can use this post in your blog so people who get this problem can get help.

    Do you or anyone else have an idea of why it stops with the state of "Paused" when trying to start the stream?

    Tuesday, July 29, 2008 8:48 AM
  •  not really sure about that one. I do all the set up programmatically in c#, so I have something like this...

             public Page() //constructor
            {
                InitializeComponent();
                media.Source = new Uri("mms://SCSTREAM.NET/;");
     

                media.MediaOpened += new RoutedEventHandler(media_MediaOpened);
                media.MediaFailed += media_MediaFailed;
                media.Play();
            }

            void media_MediaOpened(object sender, RoutedEventArgs e)
            {
                Debug.WriteLine(media.CanSeek);
            }

            void media_MediaFailed(object sender, ExceptionRoutedEventArgs e)
            {
                Debug.WriteLine(e.ErrorException.Message);
            }
     

    it seems to work fine, although I have only run the code about three times, so I may be wrong

    Tuesday, July 29, 2008 9:07 AM
  • I've still got problems with this. I have tried it on a webserver and I still can't get the stream to start.

    It starts to open the stream, closes it, opens it, plays for a millisecond and then pauses...

     

    What can I do to get it working? I'm realy out of ideas...

    Thursday, July 31, 2008 7:07 AM
  • I solved the problem! Smile It all work perfectly now! It turned out that the MediaElement couldn't load the stream in Mp3-format (I think it was in Mp3PRO-format). When using an WMA-stream it worked...

    Thanks to all for your help!

    Friday, August 01, 2008 6:54 AM
  • Hello everyone,

    This problem for me it has not been solved. The media element is being paused after 1 milisecond in IE. In Firefox it works well. Has anyone got a solution?

    It has been tested in RC0. Is there a way to contact the development team to keep that in mind ?

    Tha strange this is that is works in Firefox like a charm but in IE and Safari is being paused. I haven't tried it in Opera though. Any thoughts? I have tried everything above...

    Saturday, October 04, 2008 4:23 AM
  •  Hello,

     I have exactly the same problem : when I connect MediaElement to my server, it opens the mp3 stream, closes it, opens it again, plays some milliseconds and then pauses.

    I tried to modify MediaElement attributes like BufferingTime, but it doesn't change anything.

    Is there a way to make it work ?

    It works fine with Adobe Flash and Windows Media Player (I type the url)... then I don't understand why it couldn't work with SL2.

    Any ideas ?

    Tuesday, December 23, 2008 10:22 AM
  • I am having the problem streaming out of WMSERVICES 2008, I have setup a SL client that is not playing the content. I will follow this suggestion.

    Monday, October 25, 2010 12:00 AM
  • Hi


    I have an mp3 which works. When I use mms or asx file it does not play with Silverlight Media Player.

    http://www.goldengel.ch/temp/DJ Intro 2011.mp3

    mms://www.goldengel.ch/temp/DJ Intro 2011.mp3

    http://www.goldengel.ch/temp/AudioStream.asx


    I just want to play

    http://listen.di.fm/public5/techhouse.asx

    stream but it does not play it.


    Thanks for your advice

    Tuesday, February 15, 2011 10:46 PM
  • I found my way home!!!

    I found out that Media Element only reproduces with port 80 or another port explicitly written like 85, which is my port.

    so i declare this way

    http://123.123.123.123:85/mountpoint    and that``s all!

    I have 10 mount points and all of them reproduces pretty well. 

    Thursday, February 24, 2011 8:21 AM