private bool UpdateMediaInfo(MediaFileInfo mediaFileInfo) { if (mediaFileInfo == null) { return false; } string videoMimeType = "unknown"; string audioMimeType = "unknown"; videoFormat = mediaFileInfo.getVideoFormat(); audioFormat = mediaFileInfo.getAudioFormat(); try { videoMimeType = videoFormat.mimeType.asString(); } catch (Exception) { videoFormat = null; } try { audioMimeType = audioFormat.mimeType.asString(); } catch (Exception) { audioFormat = null; } if (videoFormat != null) { float frameRate = videoFormat.frameRate.Numerator; if (videoFormat.frameRate.Denominator != 0) { frameRate /= videoFormat.frameRate.Denominator; } VideoCodecText.Text = videoMimeType; ResolutionText.Text = String.Format("{0} x {1}", videoFormat.resolution.Width, videoFormat.resolution.Height); FramerateText.Text = String.Format("{0}", frameRate); BitrateVideoText.Text = String.Format("{0}", videoFormat.bitrate); } else { ResolutionText.Text = ""; FramerateText.Text = ""; BitrateVideoText.Text = ""; } if (audioFormat != null) { AudioCodecText.Text = audioMimeType; ChannelsText.Text = String.Format("{0}", audioFormat.channelCount); SamplerateText.Text = String.Format("{0}", audioFormat.sampleRate); BitspersampleText.Text = String.Format("{0}", audioFormat.bitsPerSample); BitrateAudioText.Text = String.Format("{0}", audioFormat.bitrate); } if (videoFormat == null && audioFormat == null) { return false; } Info.Visibility = Visibility.Visible; return true; }
private bool UpdateMediaInfo(MediaFileInfo mediaFileInfo) { if (mediaFileInfo == null) { return(false); } string videoMimeType = "unknown"; string audioMimeType = "unknown"; videoFormat = mediaFileInfo.getVideoFormat(); audioFormat = mediaFileInfo.getAudioFormat(); try { videoMimeType = videoFormat.mimeType.asString(); } catch (Exception) { videoFormat = null; } try { audioMimeType = audioFormat.mimeType.asString(); } catch (Exception) { audioFormat = null; } if (videoFormat != null) { float frameRate = videoFormat.frameRate.Numerator; if (videoFormat.frameRate.Denominator != 0) { frameRate /= videoFormat.frameRate.Denominator; } VideoCodecText.Text = videoMimeType; ResolutionText.Text = String.Format("{0} x {1}", videoFormat.resolution.Width, videoFormat.resolution.Height); FramerateText.Text = String.Format("{0}", frameRate); BitrateVideoText.Text = String.Format("{0}", videoFormat.bitrate); } else { ResolutionText.Text = ""; FramerateText.Text = ""; BitrateVideoText.Text = ""; } if (audioFormat != null) { AudioCodecText.Text = audioMimeType; ChannelsText.Text = String.Format("{0}", audioFormat.channelCount); SamplerateText.Text = String.Format("{0}", audioFormat.sampleRate); BitspersampleText.Text = String.Format("{0}", audioFormat.bitsPerSample); BitrateAudioText.Text = String.Format("{0}", audioFormat.bitrate); } if (videoFormat == null && audioFormat == null) { return(false); } Info.Visibility = Visibility.Visible; return(true); }