C# UWP MediaPlayer crash on emulator

1

I'm new to UWP, and i tried instantinate MediaPlayer class. On local machine it's work fine, but on mobile emulator throws next exception:

An exception of type 'System.Runtime.InteropServices.COMException' occurred in project.exe but was not handled in user code

Additional information: ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE))

enter image description here

StackTrace:

  • at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
  • at Windows.Media.Playback.MediaPlayer..ctor()
  • at Project.Services.PlaybackServiceFactory.Create(PlayerArgument arg)
  • at Project.ViewModels.PlayerViewModel..ctor(PlayerArgument arg)
  • at Project.MainPage.d__3.MoveNext()

All uwp examples with MediaPlayer also crashes. Previously it worked fine, whats maybe wrong? I would be glad of any help, thank you.

UPD: Problem actual for 10.0.10586 emulator version

c#
crash
uwp
asked on Stack Overflow Jan 15, 2017 by ExtremeCode • edited Jan 15, 2017 by ExtremeCode

1 Answer

1

The MediaPlayer constructor is available from "Universal, introduced version 10.0.14393.0". So please run your project in 14393 emulator or grater.

You could dynamically detect features with API contracts (10 by 10)

The Universal Windows Platform (UWP) allows you to write your app once and target multiple device families, while also taking advantage of new APIs introduced on later versions of the OS as well as using unique APIs only present on certain device families.

answered on Stack Overflow Jan 16, 2017 by Xie Steven

User contributions licensed under CC BY-SA 3.0