void SetMkvAudioLanguageList(MKVFileSource mkvFileSource) { //MediaStreamSource의 경우 Descriptor에서 Language 및 Name이 추출되지 않으며, 해당 스트림을 선택해도 작동되지 않는다. var audioLanguageList = mkvFileSource.UsableMediaCodecs.Where(x => x.CodecType == TrackTypes.Audio).Select((codec, index) => new PickerItem <string, int> { Key = index, Name = GetCodecName(codec), Payload = codec }); MessengerInstance.Send(new Message("AudioLoadedInMKV", audioLanguageList), TransportControlViewModel.NAME); }
private void SetMkvSubtitleLanguageList(MKVFileSource mkvFileSource) { var codecs = mkvFileSource.UsableSubtitleCodecs; Subtitle subtitle = null; byte[] header = null; string nameFormat = "[MKV] {0} {1}"; List <PickerItem <string, string> > list = new List <PickerItem <string, string> >(); foreach (var codec in codecs) { header = codec.TrackEntry.CodecPrivate; subtitle = new Subtitle() { SubtitleFileKind = SubtitleFileKind.Internal }; subtitle.AddLanguage(codec.TrackNumber.ToString(), new List <KeyValuePair <string, string> >()); if (codec is ASSCodec || codec is SSACodec) { //ASS의 경우 스타일 로딩 AssParser assParser = new AssParser(); assParser.LoadHeader(Encoding.UTF8.GetString(header, 0, header.Length)); subtitle.Parser = assParser; subtitle.Title = string.Format(nameFormat, GetCodecName(codec), assParser.GetTitle()); } else if (codec is SRTCodec) { subtitle.Parser = new SrtParser(); subtitle.Title = string.Format(nameFormat, GetCodecName(codec), string.Empty); } list.Add(new PickerItem <string, string> { Key = codec.TrackNumber.ToString(), Name = subtitle.Title, Payload = subtitle, Payload2 = (byte)4 }); } //재생패널 콤보에 추가 MessengerInstance.Send <Message>(new Message("SubtitlesLoaded", list), TransportControlViewModel.NAME); }
bool ValidateCodecForMkv(Document doc, MKVFileSource mkvFileSource) { DialogContent dc = new DialogContent(); ResourceLoader loader = ResourceLoader.GetForCurrentView(); IEnumerable <ICodec> codecs = mkvFileSource.UnusableMediaCodecs; //MKV가 아닌 경우 예외 발생 if (doc.Header == null || doc.Header.Count == 0) { CurrentMediaInfo.MediaType = MediaType.Unkown; dc.Content = string.Format(loader.GetString("WrongFileFormat"), "MKV"); dc.OccueredErrorMediaInfo = dc.Content; } else { var videoCodec = codecs.Where(x => x.CodecType == TrackTypes.Video); var audioCodec = codecs.Where(x => x.CodecType == TrackTypes.Audio); if (videoCodec.Any()) { dc.Content = loader.GetString("NotSupportedVideoCodec"); dc.Description1 = videoCodec.FirstOrDefault().CodecName; dc.Description2 = string.Format(loader.GetString("NotSupportedCodecDesc"), "H264"); } if (audioCodec.Any()) { var licenseCodec = audioCodec.FirstOrDefault(x => x.IsNeedLicense); if (licenseCodec != null) { dc.Content = string.Format(loader.GetString("NotSupportedAudioLicenseCodec"), licenseCodec.LicenseCompany); dc.Description1 = licenseCodec.CodecName; dc.Description2 = loader.GetString("NotSupportedLicenseCodecDesc"); } else { dc.Content = loader.GetString("NotSupportedAudioCodec"); dc.Description1 = audioCodec.FirstOrDefault(x => !x.IsNeedLicense).CodecName; dc.Description2 = string.Format(loader.GetString("NotSupportedCodecDesc"), "AAC, MP3, FLAC, PCM"); } } } if (!string.IsNullOrEmpty(dc.Content)) { //재생 종료 StopMedia(); //화면 닫기 if (IsPlayerOpened) { IsPlayerOpened = false; } //에러 메세지 처리 if (string.IsNullOrEmpty(dc.OccueredErrorMediaInfo)) { dc.OccueredErrorMediaInfo = ResourceLoader.GetForCurrentView().GetString("Message/Error/CodecNotSupported"); } //로딩 패널 숨김 HideLoadingBar(); //에러메세지 출력 ShowDialogMediaStreamSourceError(dc); return(false); } return(true); }