Beispiel #1
0
        /// <summary>
        /// Gets the actual closed caption track represented by given metadata
        /// </summary>
        public async Task <ClosedCaptionTrack> GetClosedCaptionTrackAsync(ClosedCaptionTrackInfo closedCaptionTrackInfo)
        {
            if (closedCaptionTrackInfo == null)
            {
                throw new ArgumentNullException(nameof(closedCaptionTrackInfo));
            }

            // Get
            string response = await _httpService.GetStringAsync(closedCaptionTrackInfo.Url).ConfigureAwait(false);

            var captionTrackXml = XElement.Parse(response).StripNamespaces();

            // Parse
            var captions = new List <ClosedCaption>();

            foreach (var captionXml in captionTrackXml.Descendants("text"))
            {
                string text     = captionXml.Value;
                var    offset   = TimeSpan.FromSeconds((double)captionXml.AttributeStrict("start"));
                var    duration = TimeSpan.FromSeconds((double)captionXml.AttributeStrict("dur"));

                var caption = new ClosedCaption(text, offset, duration);
                captions.Add(caption);
            }

            return(new ClosedCaptionTrack(closedCaptionTrackInfo, captions));
        }
Beispiel #2
0
        /// <inheritdoc />
        public async Task <ClosedCaptionTrack> GetClosedCaptionTrackAsync(ClosedCaptionTrackInfo info)
        {
            info.GuardNotNull(nameof(info));

            // Get manifest
            var raw = await _httpClient.GetStringAsync(info.Url).ConfigureAwait(false);

            var trackXml = XElement.Parse(raw).StripNamespaces();

            // Parse captions
            var captions = new List <ClosedCaption>();

            foreach (var captionXml in trackXml.Descendants("p"))
            {
                var text = (string)captionXml;
                if (text.IsBlank())
                {
                    continue;                 // some autogenerated captions are blank
                }
                var offset   = TimeSpan.FromMilliseconds((double)captionXml.Attribute("t"));
                var duration = TimeSpan.FromMilliseconds((double)captionXml.Attribute("d"));

                var caption = new ClosedCaption(text, offset, duration);
                captions.Add(caption);
            }

            return(new ClosedCaptionTrack(info, captions));
        }
        /// <inheritdoc />
        public async Task <ClosedCaptionTrack> GetClosedCaptionTrackAsync(ClosedCaptionTrackInfo info)
        {
            info.GuardNotNull(nameof(info));

            // Get parser
            var parser = await GetClosedCaptionTrackAjaxParserAsync(info.Url).ConfigureAwait(false);

            // Parse captions
            var closedCaptions = new List <ClosedCaption>();

            foreach (var closedCaptionParser in parser.GetClosedCaptions())
            {
                // Extract info
                var text = closedCaptionParser.ParseText();

                // Skip caption tracks without text
                if (text.IsBlank())
                {
                    continue;
                }

                var offset   = closedCaptionParser.ParseOffset();
                var duration = closedCaptionParser.ParseDuration();

                var caption = new ClosedCaption(text, offset, duration);
                closedCaptions.Add(caption);
            }

            return(new ClosedCaptionTrack(info, closedCaptions));
        }
Beispiel #4
0
        /// <inheritdoc />
        public async Task <ClosedCaptionTrack> GetClosedCaptionTrackAsync(ClosedCaptionTrackInfo info)
        {
            info.GuardNotNull(nameof(info));

            // Get parser
            var parser = await GetClosedCaptionTrackAjaxParserAsync(info.Url);

            // Parse captions
            var closedCaptions = new List <ClosedCaption>();

            foreach (var closedCaptionParser in parser.GetClosedCaptions())
            {
                // Parse info
                var text = closedCaptionParser.ParseText();

                // Skip empty or whitespace captions
                if (text == null || text.IsWhiteSpace())
                {
                    continue;
                }

                var offset   = closedCaptionParser.ParseOffset();
                var duration = closedCaptionParser.ParseDuration();

                var caption = new ClosedCaption(text, offset, duration);
                closedCaptions.Add(caption);
            }

            return(new ClosedCaptionTrack(info, closedCaptions));
        }
Beispiel #5
0
 public Call()
 {
     ClosedCaption  = new ClosedCaption();
     Participants   = new List <zCommand.ListParticipant>();
     Sharing        = new zEvent.SharingState();
     CallRecordInfo = new CallRecordInfo();
     Info           = new zCommand.InfoResult();
 }
Beispiel #6
0
 public void ResetAll()
 {
     General.ResetDefaultValue();
     Playback.ResetDefaultValue();
     ClosedCaption.ResetDefaultvalue();
     Privacy.ResetDefaultValue();
     Server.ResetDefaultValue();
     Thumbnail.ResetDefaultValue();
 }
Beispiel #7
0
 public Call()
 {
     Sharing         = new Sharing();
     Camera          = new Camera();
     Microphone      = new Microphone();
     Layout          = new Layout();
     Lock            = new Lock();
     MuteUserOnEntry = new MuteUserOnEntry();
     ClosedCaption   = new ClosedCaption();
 }
Beispiel #8
0
        public async Task PlayVideo(string videoId, ClosedCaption caption)
        {
            Caption = caption;
            var videoMedia = await YouTubeWebsite.GetVideoMediaStreamInfosAsync(videoId);

            var media = new Media(_libVLC,
                                  videoMedia.Muxed.WithHighestVideoQuality().Url,
                                  FromType.FromLocation);

            media.AddOption($":start-time={string.Format("{0:D2}.{1:D2}", (int)caption.Offset.TotalSeconds, caption.Offset.Milliseconds)}");
            media.AddOption($":run-time={string.Format("{0:D2}.{1:D2}", (int)caption.Duration.TotalSeconds, caption.Duration.Milliseconds)}");

            _mediaPlayer           = new MediaPlayer(_libVLC);
            _videoView.MediaPlayer = _mediaPlayer;
            _mediaPlayer.Play(media);
        }
        /// <summary>
        /// Gets the actual closed caption track represented by given metadata
        /// </summary>
        public async Task <ClosedCaptionTrack> GetClosedCaptionTrackAsync(ClosedCaptionTrackInfo info)
        {
            info.GuardNotNull(nameof(info));

            // Get manifest
            var response = await _httpService.GetStringAsync(info.Url).ConfigureAwait(false);

            var trackXml = XElement.Parse(response).StripNamespaces();

            // Parse captions
            var captions = new List <ClosedCaption>();

            foreach (var captionXml in trackXml.Descendants("text"))
            {
                var text     = captionXml.Value;
                var offset   = TimeSpan.FromSeconds((double)captionXml.AttributeStrict("start"));
                var duration = TimeSpan.FromSeconds((double)captionXml.AttributeStrict("dur"));

                var caption = new ClosedCaption(text, offset, duration);
                captions.Add(caption);
            }

            return(new ClosedCaptionTrack(info, captions));
        }
Beispiel #10
0
 public ClosedCaptionWrapperClass(ClosedCaption c)
 {
     Parent = c;
 }
        static void Main(string[] args)
        {
            var CCOb = new ClosedCaptions();

            //read original local file
            CCOb.Read("E:/Blender A new Generation/Scripts/alyx/subtitles/closecaption_english.bak.dat");



            /*
             * uint strHask = ValveResourceFormat.Crc32.Compute(System.Text.Encoding.Unicode.GetBytes("<clr:18,199,226>Alyx confirmed."));
             * Console.WriteLine(strHask);
             * foreach (var item in CCOb.Captions)
             * {
             *  if (item.Hash == strHask) Console.WriteLine("Its the HASH");
             *  if (item.UnknownV2 == strHask) Console.WriteLine("Its the Unkown" + strHask);
             * }
             *
             */

            //adding own caption
            ushort offset = 0;

            foreach (var item in CCOb.Captions.FindAll((e) => { return(e.Blocknum == 130); }))
            {
                offset += item.Length;
            }

            var cap = new ClosedCaption
            {
                Hash      = ValveResourceFormat.Crc32.Compute(System.Text.Encoding.Unicode.GetBytes("vo.OwnVoice")),
                Blocknum  = 130,
                Offset    = offset,
                Length    = (ushort)System.Text.Encoding.Unicode.GetBytes("<clr:19,199,226>MyOwnLine").Length,
                UnknownV2 = ValveResourceFormat.Crc32.Compute(System.Text.Encoding.Unicode.GetBytes("<clr:19,199,226>MyOwnLine"))
            };

            //ClosedCaptions.directorysize+=1;
            cap.Text = "<clr:19,199,226>MyOwnLine";
            //CCOb.Captions.Add(cap);


            //replaces text with Testing
            int currblocknum = 0;
            int curroffset   = 0;

            foreach (var item in CCOb.Captions)
            {
                item.Text      = "Testing";
                item.Length    = (ushort)System.Text.Encoding.Unicode.GetBytes(item.Text).Length;
                item.UnknownV2 = ValveResourceFormat.Crc32.Compute(System.Text.Encoding.Unicode.GetBytes(item.Text));
                item.Offset    = (ushort)(curroffset);
                if (item.Offset + item.Length >= ClosedCaptions.blocksize)
                {
                    item.Offset = 0;
                    currblocknum++;
                    curroffset = 0;
                }
                item.Blocknum = currblocknum;
                curroffset   += item.Length;
            }
            ClosedCaptions.numblocks = (uint)currblocknum;
            Console.WriteLine(ClosedCaptions.blocksize);
            Console.WriteLine(ClosedCaptions.dataoffset);
            Console.WriteLine(ClosedCaptions.directorysize);
            Console.WriteLine(ClosedCaptions.numblocks);
            Console.WriteLine(ClosedCaptions.version);
            Console.WriteLine(CCOb.Captions.Count);
            //Write to file
            write("closecaption_english.dat", CCOb.Captions, File.OpenWrite("E:/Blender A new Generation/Scripts/alyx/subtitles/closecaption_english.dat"));
        }
Beispiel #12
0
        public static async Task <Stream> GetVideoClip(MuxedStreamInfo info, TimeSpan duration, ClosedCaption caption)
        {
            var secondLength = info.Size / (duration.TotalSeconds);
            var startRange   = (caption.Offset.TotalSeconds * secondLength) + 1;
            var endRange     = ((caption.Offset.TotalSeconds + caption.Duration.TotalSeconds) * secondLength) + 1;
            var testCurl     = $"curl \"{info.Url}\" -H \"Range: bytes={(long)startRange}-{(long)endRange}\" -o ten_secs.mp4";

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Range = new System.Net.Http.Headers.RangeHeaderValue((long)startRange, (long)endRange);
                return(await client.GetStreamAsync(info.Url));
            }
        }
 public async Task PlayVideo(string videoId, ClosedCaption caption)
 {
     await viewModel.PlayVideo(videoId, caption);
 }