Beispiel #1
0
 public ScriptMediaMarker(MediaMarker marker)
 {
     Content = marker.Content;
     Id      = marker.Id;
     Begin   = marker.Begin.TotalSeconds;
     End     = marker.End.TotalSeconds;
     Type    = marker.Type;
 }
        private void Timeline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var         sourceElement = e.OriginalSource as FrameworkElement;
            MediaMarker marker        = sourceElement != null
                                     ? sourceElement.DataContext as MediaMarker
                                     : null;

            if (marker != null && MarkerSelected != null)
            {
                MarkerSelected(this, new CustomEventArgs <MediaMarker>(marker));
            }
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            // use live position when in live, otherwise end position,
            // this is the bounds where markers are visisble
            TimeSpan endPosition = IsLive && LivePosition.HasValue && !DisplayMarkersOutsideLiveWindow
                                       ? LivePosition.Value
                                       : EndPosition;

            if (endPosition > StartPosition)
            {
                // go through each marker control and layout on the timeline
                foreach (UIElement childControl in Children)
                {
                    var         contentPresenter = childControl as ContentPresenter;
                    MediaMarker mediaMarker      = contentPresenter != null
                                                  ? contentPresenter.Content as MediaMarker
                                                  : null;

                    if (mediaMarker != null)
                    {
                        // make sure the marker is within the timeline range
                        if (mediaMarker.Begin < StartPosition || mediaMarker.Begin > endPosition)
                        {
                            // don't display the marker
                            childControl.Arrange(new Rect(0, 0, 0, 0));
                        }
                        else
                        {
                            // convert the absolute time to a relative timeline time
                            TimeSpan time = mediaMarker.Begin - StartPosition;

                            // calculate the top position, center the marker vertically
                            double top = (finalSize.Height - childControl.DesiredSize.Height) / 2;

                            // calculate the left position, first get the pixel position within the timeline
                            double left = (time.TotalSeconds * (finalSize.Width - ThumbWidth)) /
                                          (endPosition.TotalSeconds - StartPosition.TotalSeconds);

                            // next adjust the position so the center of the control is at the time on the timeline,
                            // note that the marker control can overhang the left or right side of the timeline
                            left += ((ThumbWidth - childControl.DesiredSize.Width) / 2);

                            // display the marker
                            childControl.Arrange(new Rect(left, top, childControl.DesiredSize.Width,
                                                          childControl.DesiredSize.Height));
                        }
                    }
                }
            }

            return(base.ArrangeOverride(finalSize));
        }
        private void Item_PositionChanged(MediaMarker item)
        {
            var tItem = item as TMediaMarker;

            if (tItem != null)
            {
                _suspendCollectionChangedEvents = true;
                Remove(tItem);
                Add(tItem);
                _suspendCollectionChangedEvents = false;
                MarkerPositionChanged.IfNotNull(i => i(tItem));
            }
        }
        private void MediaElement_MarkerReached(object sender, TimelineMarkerRoutedEventArgs e)
        {
            string logMessage = string.Format(ProgressiveMediaPluginResources.TimelineMarkerReached, e.Marker.Time,
                                              e.Marker.Type, e.Marker.Text);

            SendLogEntry(KnownLogEntryTypes.MediaElementMarkerReached, message: logMessage);

            var mediaMarker = new MediaMarker
            {
                Type    = e.Marker.Type,
                Begin   = e.Marker.Time,
                End     = e.Marker.Time,
                Content = e.Marker.Text
            };

            NotifyMarkerReached(mediaMarker);
        }
        public string SecondsToText(double seconds)
        {
            TimeSpan ts = TimeSpan.FromSeconds(seconds);

            return(MediaMarker.Format(ts));
        }
 private void NotifyMarkerReached(MediaMarker mediaMarker)
 {
     MarkerReached.IfNotNull(i => i(this, mediaMarker));
 }
Beispiel #8
0
 public static string ToString(this MediaMarker Marker)
 {
     return(String.Format("[{0}]{1}: {2}", Marker.Index, Marker.Position, Marker.Label));
 }