Please, install a trial version of 'Resharper' then review the code. Go "Extensions -> ReSharper -> Inspect -> Code Issues in Solution". There is a multiple dangerous points causing 'NullReferenceException', for example. See attachments.
private void OnMediaOpening(object sender, MediaOpeningEventArgs e)
{
// use 'as' only if you not sure
var media = sender as MediaElement; // <- bad
// cast directly to emphasize your intention
var media = (MediaElement)sender; // <- good
}
Thanks for reporting. These issues have been addressed. on the casting matter I understand. The use of as is much less expensive than direct casting and that's why I prefer it. The other items I have changed.
Multiple threats of 'NullReferenceException'
Please, install a trial version of 'Resharper' then review the code. Go "Extensions -> ReSharper -> Inspect -> Code Issues in Solution". There is a multiple dangerous points causing 'NullReferenceException', for example. See attachments.
Issue Categories
Version Information
Samples of Issues
await null in CaptureBitmapAsync()
A null propagation always returns a value and await operator always expect the value. If the null propagation returns null then will be done something like "((Task)null).GetAwaiter().GetResult()". https://github.com/unosquare/ffmediaelement/blob/master/Unosquare.FFME.Windows/MediaElement.cs
'default' keyword in non-generic type 'Subtitles'
The 'GetFontSize' method returns a value-type 'double', but 'default' keyword returns 'object' that is reference type. The null-coalescing operand returns default reference-type value, which is 'null'. You cannot cast 'null' to 'double'. Use 'default(double)' instead. https://github.com/unosquare/ffmediaelement/blob/master/Unosquare.FFME.Windows/Subtitles.cs
There is the same problem in 'GetFontWeight' and 'GetOutlineWidth' methods.
Other recommendations
https://github.com/unosquare/ffmediaelement/blob/master/Unosquare.FFME.Windows.Sample/MainWindow.MediaEvents.cs
Attachments
https://www.dropbox.com/s/6a7y587x6o1zxob/Unosquare_code_issues.zip?dl=0