Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

windows 8 - MediaElement in WinRT / Win8 does not work at all

I'm getting really frustrated with WinRT (Windows 8 apps). I've been running into a lot of problems with the most basic functionality and no documentation to support it.

So, here's my next question of the series I've already posted regarding WinRT:

<MediaElement Width="500" 
              Height="500"
              Source="ms-appx:///Assets/SampleVideo.wmv" />

Why doesn't this work?!!!

  • No video displays.
  • No audio played.
  • No error messages.
  • No exceptions thrown.

None of these events are raised:

  • MediaOpened
  • MediaFailed
  • MediaEnded
  • SeekCompleted
  • DownloadProgressChanged
  • BufferingProgressChanged

The only event raised is CurrentStateChanged which happens when the State is "Opening". And that's it. Nothing else happens.

I tried doing it manually using a stream like this:

var packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assetsFolder = await packageLocation.GetFolderAsync("Assets");
var myVideo = await assetsFolder.GetFileAsync("SampleVideo.wmv");
var stream = await myVideo.OpenAsync(FileAccessMode.Read);

_Player.SetSource(stream, myVideo.ContentType);
_Player.Play();

This doesn't work either. Same inactivity.

The SampleVideo.wmv file is build type Content and I can open it fine in Windows Media Player and Zune. So there's absolutely no problems with the video file. However, I did try other files, like MP4, AVI, etc. Nothing works.

Is anyone else having problems? Any help would be appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After 48 hours of research and painful trial n' error, I found this link on the MSDN forums.

In the end, Windows 8 does not bubble up exceptions to the app. The MediaElement silently fails, while all other video players run fine.

The solution: if you have Bootcamp on any Mac Laptop/Desktop, then go directly to the graphics manufacturer and download their latest drivers. For me, I have a MacBook Pro 17" and it uses the AMD Radeon 6600m series. The drivers can be found here for 64-bit versions.

Anyway, my apologies for wasting anyone's time.

Thanks @JimO'Neil for trying to help :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...