Reputation: 1794
I am working on some library written for UWP apps. My library has set up:
I have MediaPlayerElement
there and would like to check video URL. There was introduced Uri property in 15063.
Gets the URI associated with the MediaSource.
Device family: Windows 10 Creators Update (introduced v10.0.15063.0) API contract: Windows.Foundation.UniversalApiContract (introduced v4)
I thought that I could use something like this:
if (ApiInformation.IsPropertyPresent(typeof(MediaSource).FullName, "Uri"))
{
return (element.MediaPlayer.Source as MediaPlaybackItem)?.Source?.Uri.AbsoluteUri;
}
It actually works but I found out that there is a problem when I include my library to an application which has:
Exception thrown: 'System.MissingMethodException' in ..............
Method not found: 'System.Uri Windows.Media.Core.MediaSource.get_Uri()'.
try/catch
does not help in this case.
Is there anything else what I can do?
Upvotes: 0
Views: 268
Reputation: 13850
Put the code that accesses the URI property into a separate method that you call from within the if-statement. This should avoid the missing method exception. This is because of the way .NET resolves the method calls dynamically on a per-method basis. On 14393 it would never get to that new method, so you won't get an exception.
Upvotes: 1
Reputation: 374
There is nothing you could do for that. The only solution is to set the minimum version of you app to 15063 and to ask the target device to update the Windows 10 version to the minimum version or above. I am myself using the MediaPlayerElement
in my existing app and was forced to set minimum version to 15063.
Also you cannot catch these kinds of errors using try catch
.
Upvotes: 0