text: Asked by:
  MediaElement problem with .mp4 file over 10MB when loaded with XAP relative URI with file scheme
  MediaElement.MediaFailed gets raised when MediaElement source is set to a XAP relative URI (leading /) when the file being pointed to is a .mp4 file larger than 10MB and the hosting html page is viewed using file scheme/protocol. The XAML to reproduce this problem is simple...
  <MediaElement Source="/media.mp4" AutoPlay="True"/>
  Note that .mp4 files smaller than 10MB and .wmv files larger than 10MB play as expected. If the hosting html page is viewed using http protocol, there isn't a problem with .mp4 files larger than 10MB. Also, note that the media files are not actually in the XAP, but in the same directory.
  I've worked around this problem, but at the expense of a well organized solution. The reason I'm using a XAP relative URI is that my full blown solution uses library projects and solution folders to organize controls. One of the controls uses a MediaElement. To work around this problem, I had to use a regular relative URI (removing the /) and move my control to the root of the project (leaving the namespace alone). This works. If I wanted to maintain organization, I would need to put the media files in a directory structure that mimics the solution folders...and I definitely don't want to do that.
  I'm okay with my temporary solution, but it would be nice to see this bug explained and fixed.
  General discussion
  All replies
  Hi joe_domoto,
  When MediaFailed is invoked, please look into e.ErrorException.Message and check which exception is thrown.
  If the hosting html page is viewed using http protocol, there isn't a problem with .mp4 files larger than 10MB.
  Do you mean the problem only happens on aspx page or when host with https protocol.
  please add more details to this problem and help me to reproduce this issue.
  Best Regards,
  Error code is 3137. I'm saying I don't see this problem when http protocol is used. The reason I pointed this out it to make it clear that there isn't a problem with MediaElement playing back the files I'm using (in terms of codec). The ONLY case where I see this problem is when the hosting page (html file) is opened using file protocol. The scenario might be that the hosting page and media are on a cd/dvd. Or the hosting page is opened directly from Windows Explorer. This should be very easy to reproduce.
  1. Create two mp4 files. One smaller and one larger than 10MB (small.mp4 and large.mp4).
  2. Create a Silverlight application project, but don't associate to a web project. Build and run. Note that the auto generated test page is used and that the browser address shows that file scheme is in use.
  3. Copy mp4 files to bin\debug folder.
  4. Add the following xaml to MainPage.xaml...
  <StackPanel Orientation="Horizontal">
  <MediaElement AutoPlay="True" Source="/small.mp4" Width="320" Height="240"/>
  <MediaElement AutoPlay="True" Source="/large.mp4" Width="320" Height="240"/>
  </StackPanel>
  5. Run. Note that one plays and the other doesn't.