Skip to main content
Home Forums General Silverlight Getting Started MediaElement, Canvas and error 4001
3 replies. Latest Post by ZeroKoll on July 4, 2009.
(0)
TheRekz
Member
4 points
40 Posts
07-03-2009 4:31 AM |
I have an array of canvas and MediaElement, 9 each. I also have a canvas, called GameContainer and tried to add those little canvas to the large canvas.
The problem is that whenever I try to run the code it gives me the error:
Code: 4001 Category: MediaError Message: AG_E_NETWORK_ERROR
Why is this?? Below is the code
</P><PRE id=codeSnippet357468 class=prettyprint>Canvas[] cI = new Canvas[9]; MediaElement[] me = new MediaElement[9]; int[] board = new int[9]; int seconds = 0; int hrs = 0; int mins = 0; int blockSizeW = 97; int blockSizeH = 97; void InitBoard() { int nx = 0; for (int ix = 0; ix < 3; ix++) for (int iy = 0; iy < 3; iy++) { nx = (ix * 3) + iy; me[nx] = new MediaElement(); me[nx].Height = 300; me[nx].Width = 300; me[nx].Stretch = Stretch.UniformToFill; RectangleGeometry r = new RectangleGeometry(); r.Rect = new Rect((ix * blockSizeW), (iy * blockSizeH), blockSizeW, blockSizeH); me[nx].Clip = r; me[nx].Source = new Uri("Wildlife.wmv", UriKind.Relative); me[nx].SetValue(Canvas.TopProperty, Convert.ToDouble(iy * blockSizeH * -1)); me[nx].SetValue(Canvas.LeftProperty, Convert.ToDouble(ix * blockSizeW * -1)); cI[nx] = new Canvas(); cI[nx].Width = blockSizeW; cI[nx].Height = blockSizeH; cI[nx].Children.Add(me[nx]); cI[nx].SetValue(Canvas.NameProperty, "C" + nx.ToString()); cI[nx].MouseLeftButtonDown += new MouseButtonEventHandler(Page_MouseLeftButtonDown); if (nx < 8) GameContainer.Children.Add(cI[nx]); } shuffle(); drawBoard(); } and how do I post code in this forum??
jay nana...
Contributor
3388 points
624 Posts
07-03-2009 5:06 AM |
can you share the code you use for setting source property of MediaElement?
rleclerc
10 points
15 Posts
07-03-2009 10:28 AM |
If I remember correctly, I think I've gotten the AG_NETWORK_ERROR when my source URI was malformed or it was a dead link. Find a URI on the web to a wmv movie and try to run it. For testing I set up IIS on my machine and point it to http://localhost/mymedia.wmv
ZeroKoll
Participant
752 points
130 Posts
07-04-2009 6:06 PM |
Error 4001 is generally if your Uri to the media is incorrect. It can also be that you are trying to change protocoll. If you are using VS to build your application and you use the HTML page to preview your SL application. This sometimes loads it using the file:// instead of http://. If you then try to load the media using http:// it will fail.
But if you could show the code you use to set the source, it would be a lot easier to help you...
I think you might get better error messages if you use VS to debug the application. The JavaScript error messages are not always that great...