Skip to main content

Microsoft Silverlight

Answered Question MediaElement, Canvas and error 4001RSS Feed

(0)

TheRekz
TheRekz

Member

Member

4 points

40 Posts

MediaElement, Canvas and error 4001

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 &lt; 3; ix++) for (int iy = 0; iy &lt; 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 &lt; 8) GameContainer.Children.Add(cI[nx]); } shuffle(); drawBoard(); } and how do I post code in this forum??

jay nanavati
jay nana...

Contributor

Contributor

3388 points

624 Posts

Re: MediaElement, Canvas and error 4001

can you share the code you use for setting source property of MediaElement?

Jay K Nanavaty
www.technologyopinion.com
Mark as answer if it helps. It will also help others...

rleclerc
rleclerc

Member

Member

10 points

15 Posts

Re: MediaElement, Canvas and error 4001

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
ZeroKoll

Participant

Participant

752 points

130 Posts

Answered Question

Re: MediaElement, Canvas and error 4001

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...

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities