Пример #1
0
 public void SaveCaptionsCommentsAudio(CaptionRegion captions, ZipFile zip, string zipFolder = "")
 {
     foreach (CaptionElement caption in captions.Children) //save any CommentsAudio associated to each caption
     {
         SaveCaptionCommentsAudio(caption, zip, zipFolder);
     }
 }
        private static CaptionRegion MapToCaptionRegion(RegionElement regionElement)
        {
            var endTime = regionElement.End.TotalSeconds >= TimeSpan.MaxValue.TotalSeconds
                            ? TimeSpan.MaxValue
                            : TimeSpan.FromSeconds(regionElement.End.TotalSeconds);

            var captionRegion = new CaptionRegion
            {
                Id    = regionElement.Id,
                Begin = TimeSpan.FromSeconds(regionElement.Begin.TotalSeconds),
                End   = endTime,
                Style = TimedTextStyleParser.MapStyle(regionElement, null)
            };

            foreach (TimedTextElementBase element in regionElement.Children)
            {
                TimedTextElement child = BuildTimedTextElements(element, null);
                if (child != null && child.CaptionElementType == TimedTextElementType.Animation)
                {
                    captionRegion.Animations.Add(child as TimedTextAnimation);
                }
            }

            return(captionRegion);
        }
        private void CreatePlaylist()
        {
            var playlistItem = new Core.Media.PlaylistItem();
            playlistItem.MediaSource = new Uri("http://ecn.channel9.msdn.com/o9/content/smf/smoothcontent/elephantsdream/Elephants_Dream_1024-h264-st-aac.ism/manifest");
            playlistItem.DeliveryMethod = DeliveryMethods.AdaptiveStreaming;

            var region = new CaptionRegion();
            playlistItem.Captions.Add(region);

            var caption1 = new CaptionElement
            {
                Begin = TimeSpan.Zero,
                End = TimeSpan.FromSeconds(10),
                Content = "This marker should display from 00:00:00 to 00:00:10 and the text should be red."
            };
            caption1.Style.Color = Colors.Red;
            caption1.Style.FontSize.Unit = LengthUnit.Pixel;
            caption1.Style.FontSize.Value = 15;
            region.Children.Add(caption1);

            var caption2 = new CaptionElement
            {
                Begin = TimeSpan.FromSeconds(20),
                End = TimeSpan.FromSeconds(30),
                Content = "This marker should display from 00:00:20 to 00:00:30 and the text should be yellow."
            };
            caption2.Style.Color = Colors.Yellow;
            caption2.Style.FontSize.Unit = LengthUnit.Pixel;
            caption2.Style.FontSize.Value = 15;
            region.Children.Add(caption2);

            player.Playlist.Add(playlistItem);
        }
Пример #4
0
 public void SaveCaptionsExtraData(CaptionRegion captions, ZipFile zip, string zipFolder = "")
 {
     foreach (CaptionElement caption in captions.Children) //save any ExtraData associated to each caption
     {
         SaveCaptionExtraData(caption, zip, zipFolder);
     }
 }
Пример #5
0
 public void LoadCaptionsCommentsAudio(CaptionRegion captions, ZipFile zip, string zipFolder = "")
 {
     //load any CommentsAudio associated to each caption
     foreach (CaptionElement caption in captions.Children)
     {
         LoadCaptionCommentsAudio(caption, zip, zipFolder);
     }
 }
Пример #6
0
 public void LoadCaptionsExtraData(CaptionRegion captions, ZipFile zip, string zipFolder = "")
 {
     //load any caption extra data associated to each caption
     foreach (CaptionElement caption in captions.Children)
     {
         LoadCaptionExtraData(caption, zip, zipFolder);
     }
 }
Пример #7
0
 private void LoadCaptions(CaptionRegion captions, ZipFile zip, string zipFolder = "")
 {
     foreach (string ext in CaptionsWindowFactory.SUPPORTED_FILE_EXTENSIONS)
     {
         foreach (ZipEntry captionsEntry in zip.SelectEntries("*" + ext, zipFolder))
         {
             using (Stream zipStream = captionsEntry.OpenReader())                        //closing stream when done
                 gridCaptions.LoadCaptions(captions, zipStream, captionsEntry.FileName);  //merge multiple embedded caption files (if user added them by hand to the saved state file, since we save only DEFAULT_CAPTIONS file, not multiple caption files)
         }
     }
 }
Пример #8
0
        public override void SaveOptions(ZipFile zip, string zipFolder = "")
        {
            base.SaveOptions(zip, zipFolder);

            CaptionRegion captions = CaptionsGridView.Captions;

            //save captions
            SaveCaptions(captions, zip, zipFolder);
            SaveCaptionsExtraData(captions, zip, zipFolder);

            //save revoicing audio
            //if (CaptionsGridView.AudioVisible || CaptionsGridView.SaveInvisibleAudio) //TODO: removed, need to fix this (maybe with separate Audio property or something?), since currently Captions is synced between components and if only some save the audio, it may be lost at load, depending on the load order of those components by their parent (activity)
            SaveCaptionsAudio(captions, zip, zipFolder); //...maybe if captions property is bound to a parent (activity), save the captions/audio there once

            //save comments audio
            SaveCaptionsCommentsAudio(captions, zip, zipFolder);
        }
Пример #9
0
        public override void LoadOptions(ZipFile zip, string zipFolder = "")
        {
            base.LoadOptions(zip, zipFolder);

            CaptionRegion newCaptions = new CaptionRegion();

            //load captions
            LoadCaptions(newCaptions, zip, zipFolder);
            LoadCaptionsExtraData(newCaptions, zip, zipFolder); //load Comments, RTL, etc. fields that can't be stored in SRT file

            //load revoicing audio
            LoadCaptionsAudio(newCaptions, zip, zipFolder);

            //load comments audio
            LoadCaptionsCommentsAudio(newCaptions, zip, zipFolder);

            CaptionsGridView.Captions = newCaptions; //TODO: see why this is needed (two-way data-binding doesn't seem to work?)
        }
        private void CreatePlaylist()
        {
            var playlistItem = new Core.Media.PlaylistItem();

            playlistItem.MediaSource    = new Uri("http://ecn.channel9.msdn.com/o9/content/smf/smoothcontent/elephantsdream/Elephants_Dream_1024-h264-st-aac.ism/manifest");
            playlistItem.DeliveryMethod = DeliveryMethods.AdaptiveStreaming;

            var region = new CaptionRegion();

            playlistItem.Captions.Add(region);

            var caption1 = new CaptionElement
            {
                Begin   = TimeSpan.Zero,
                End     = TimeSpan.FromSeconds(10),
                Content = "This marker should display from 00:00:00 to 00:00:10 and the text should be red."
            };

            caption1.Style.Color          = Colors.Red;
            caption1.Style.FontSize.Unit  = LengthUnit.Pixel;
            caption1.Style.FontSize.Value = 15;
            region.Children.Add(caption1);

            var caption2 = new CaptionElement
            {
                Begin   = TimeSpan.FromSeconds(20),
                End     = TimeSpan.FromSeconds(30),
                Content = "This marker should display from 00:00:20 to 00:00:30 and the text should be yellow."
            };

            caption2.Style.Color          = Colors.Yellow;
            caption2.Style.FontSize.Unit  = LengthUnit.Pixel;
            caption2.Style.FontSize.Value = 15;
            region.Children.Add(caption2);

            player.Playlist.Add(playlistItem);
        }
 private void CaptionManager_MarkerLeft(MediaMarkerManager<CaptionRegion> captionManager, CaptionRegion region)
 {
     OnCaptionRegionLeft(region);
 }
 private void CaptionManager_MarkerReached(MediaMarkerManager<CaptionRegion> captionManager, CaptionRegion region, bool skippedInto)
 {
     OnCaptionRegionReached(region);
 }
        /// <summary>
        /// Raises the CaptionReached event.
        /// </summary>
        protected virtual void OnCaptionRegionReached(CaptionRegion region)
        {
            try
            {
                string message = string.Format(SilverlightMediaFrameworkResources.CaptionRegionReachedLogMessage,
                                               region.Id);
                SendLogEntry(message: message, type: KnownLogEntryTypes.CaptionRegionReached);

                VisibleCaptions.Add(region);
                CaptionReached.IfNotNull(i => i(this, new CustomEventArgs<CaptionRegion>(region)));
            }
            catch (Exception err)
            {
                string message = string.Format(SilverlightMediaFrameworkResources.GenericErrorOccurredLogMessage,
                                               "OnCaptionRegionReached", err.Message);
                SendLogEntry(KnownLogEntryTypes.GeneralErrorOccurred, LogLevel.Error, message);
            }
        }
 public InStreamClearTextCaptionsPlugin()
 {
     _captionRegion = new CaptionRegion();
 }
        private static CaptionRegion MapToCaptionRegion(RegionElement regionElement)
        {
            var endTime = regionElement.End.TotalSeconds >= TimeSpan.MaxValue.TotalSeconds
                            ? TimeSpan.MaxValue
                            : TimeSpan.FromSeconds(regionElement.End.TotalSeconds);

            var captionRegion = new CaptionRegion
            {
                Id = regionElement.Id,
                Begin = TimeSpan.FromSeconds(regionElement.Begin.TotalSeconds),
                End = endTime,
                Style = TimedTextStyleParser.MapStyle(regionElement, null)
            };

            foreach (TimedTextElementBase element in regionElement.Children)
            {
                TimedTextElement child = BuildTimedTextElements(element, null);
                if (child != null && child.CaptionElementType == TimedTextElementType.Animation)
                {
                    captionRegion.Animations.Add(child as TimedTextAnimation);
                }
            }

            return captionRegion;
        }
 private void CaptionPositionChanged(CaptionRegion captionRegion)
 {
     if (ActiveMediaPlugin != null && _captionManager != null)
     {
         _captionManager.CheckMarkerPosition(RelativeMediaPluginPosition, captionRegion);
     }
 }
Пример #17
0
 private void SaveCaptions(CaptionRegion captions, ZipFile zip, string zipFolder = "")
 {
     zip.AddEntry(zipFolder + "/" + DEFAULT_CAPTIONS, SaveCaptions); //SaveCaptions(string, Stream) is callback method //saving even when no captions are available as a placeholder for user to edit manually
 }
Пример #18
0
        public BaseWindow AddWindow(IWindowFactory windowFactory, bool newInstance = false)
        {
            try
            {
                BaseWindow w = windowFactory.CreateWindow();

                if (!newInstance)
                {
                    AddWindow(w);
                }
                else
                {                                                   //TODO: must change this scheme to remove hardcoded logic here, by using reverse binding order (source=container, target=component) when adding a new component manually than when loading saved state
                    TimeSpan      activityTime     = View.Time;     //Since settings Captions can change Time (jump to 0), must cache it here
                    CaptionRegion activityCaptions = View.Captions; //Since we use it at various if/else clauses below, better do this once here (doesn't cost much) to generate smaller compiled code

                    //for new child window instances (that the user adds), must reset their properties to match their containers so that they don't cause other components bound to the container to lose their Time/Captions when these get bound as sources to the container (which AddWindow does by calling BindWindow)
                    if (w is MediaPlayerWindow)
                    {
                        IMediaPlayer v = ((MediaPlayerWindow)w).MediaPlayerView;
                        //v.Captions = activityCaptions; //first set Captions, then Time //Note: this one is not needed since we added reverse binding logic for the Clip component (both at loading from saved state and for new one added in activity) - it doesn't store captions in its saved state
                        v.Time = activityTime;
                    }
                    else if (w is CaptionsWindow)
                    {
                        ICaptionsGrid v = ((CaptionsWindow)w).CaptionsGridView;
                        v.Captions = activityCaptions; //first set Captions, then Time
                        v.Time     = activityTime;
                    }
                    else if (w is TextEditorWindow)
                    {
                        ITextEditor2 v = ((TextEditorWindow)w).TextEditorView2;
                        //v.Captions = activityCaptions; //first set Captions, then Time
                        v.Time = activityTime;
                    }
                    else if (w is ImageWindow)
                    {
                        IImageViewer v = ((ImageWindow)w).ImageView;
                        v.Time = activityTime;
                    }
                    else if (w is MapWindow)
                    {
                        IMapViewer v = ((MapWindow)w).MapView;
                        //v.Captions = activityCaptions; //first set Captions, then Time
                        v.Time = activityTime;
                    }
                    else if (w is NewsWindow)
                    {
                        INewsReader v = ((NewsWindow)w).NewsView;
                        //v.Time = activityTime; //doesn't use the Time property
                    }
                    else if (w is BrowserWindow)
                    {
                        IBrowser v = ((BrowserWindow)w).BrowserView;
                        //v.Time = activityTime; //doesn't use the Time property
                    }
                    else if (w is GalleryWindow)
                    {
                        IGallery v = ((GalleryWindow)w).GalleryView;
                        //v.Time = activityTime; //doesn't use the Time property
                    }
                    AddWindowInViewCenter(w);
                };

                return(w);
            }
            catch (Exception e)
            {
                ErrorDialog.Show("Failed to create component", e);
                return(null);
            }
        }
 public InStreamClearTextCaptionsPlugin()
 {
     _captionRegion = new CaptionRegion();
 }