private async Task FF_ExternalAudioOpen(string audioSource) { try { string jsonOutput = await FFProbe.GetMediaInfo(audioSource); using JsonDocument jsonDocument = JsonDocument.Parse(jsonOutput); JsonElement streamsElement = jsonDocument.RootElement.GetProperty("streams"); JsonElement audioStreamElement = new JsonElement(); // Find first audio stream for (int i = 0; i < streamsElement.GetArrayLength(); i++) { if (streamsElement[i].GetProperty("codec_type").GetString() == "audio") { audioStreamElement = streamsElement[i]; break; } } AudioTrack audioTrack = AudioTrack.FromJson(audioStreamElement); audioTracks = new AudioTrack[] { audioTrack }; ExternalAudioCodec = audioTrack.Codec; Size += audioTrack.Size; } catch (Exception) { // Since it's not possible to create a Window from this thread, every exception is rethrown; whoever called this method will have to show the user the error throw; } }
private async Task FF_Open(string source) { try { string jsonOutput = await FFProbe.GetMediaInfo(source); await Task.Run(() => ParseJson(jsonOutput)).ConfigureAwait(false); ColorInfo = await GetColorInfo(source); } catch (Exception) { // Since it's not possible to create a Window from this thread, every exception is rethrown; whoever called this method will have to show the user the error throw; } }