コード例 #1
0
        Subtitle CreateSubtitle(SubtitleInfomation subtitleInfomation)
        {
            if (subtitleInfomation.type != SubtitlePacketType.SUBTITLE_ASS &&
                subtitleInfomation.type != SubtitlePacketType.SUBTITLE_TEXT)
            {
                return(null);
            }

            Subtitle subtitle   = null;
            string   nameFormat = "[MKV] {0}";

            subtitle = new Subtitle()
            {
                SubtitleFileKind = SubtitleFileKind.Internal
            };
            subtitle.AddLanguage(subtitleInfomation.language + ":" + subtitleInfomation.streamIndex, new List <KeyValuePair <string, string> >());

            if (subtitleInfomation.type == SubtitlePacketType.SUBTITLE_ASS)
            {
                //ASS의 경우 스타일 로딩
                AssParser assParser = new AssParser();
                assParser.LoadHeader(subtitleInfomation.header);

                subtitle.Parser = assParser;
                subtitle.Title  = string.Format(nameFormat, GetSubtitleName(subtitleInfomation));
            }
            else if (subtitleInfomation.type == SubtitlePacketType.SUBTITLE_TEXT)
            {
                subtitle.Parser = new SrtParser();
                subtitle.Title  = string.Format(nameFormat, GetSubtitleName(subtitleInfomation));
            }

            return(subtitle);
        }
コード例 #2
0
        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);
        }