void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
        {
            var trackedEventList = ResultsEventList.ItemsSource as ObservableCollection <EventTrackedEventArgs>;

            trackedEventList.Add(e);
            Debug.WriteLine(string.Format("{1} - tracked: {0}", e.TrackingEvent.Data, e.Timestamp));
        }
        private void TrackVideoViewMarker(string url, EventTrackedEventArgs e)
        {
            if (!trackingEnded)
            {
                bool     isStart;
                bool     isEnd;
                TimeSpan currentPlayTime;
                if (e.TrackingEvent is PositionTrackingEvent)
                {
                    var playTimeTrackingPlugin = MediaPlayer.Plugins.OfType <PlayTimeTrackingPlugin>().FirstOrDefault();
                    if (playTimeTrackingPlugin == null)
                    {
                        throw new Exception("PlayTimeTrackingPlugin not found; required for FreeWheelPlugin");
                    }
                    var positionTrackingEvent = (PositionTrackingEvent)e.TrackingEvent;
                    if (!positionTrackingEvent.PositionPercentage.HasValue || positionTrackingEvent.PositionPercentage.Value != 1)
                    {
                        throw new Exception("Invalid tracking event was registered for FreeWheelPlugin");
                    }
                    isStart         = false;
                    isEnd           = true;
                    currentPlayTime = playTimeTrackingPlugin.PlayTime;
                    trackingEnded   = true; // set this flag to prevent further tracking
                }
                else if (e.TrackingEvent is PlayTimeTrackingEvent)
                {
                    var playTimeTrackingEvent = (PlayTimeTrackingEvent)e.TrackingEvent;
                    isStart         = playTimeTrackingEvent.PlayTime == TimeSpan.Zero;
                    isEnd           = false;
                    currentPlayTime = playTimeTrackingEvent.PlayTime;
                }
                else
                {
                    throw new ArgumentException();
                }

                TimeSpan delta;
                if (lastTrackingEvent != null)
                {
                    delta = currentPlayTime - lastTrackingEvent.PlayTime;
                }
                else
                {
                    delta = currentPlayTime;
                }
                lastTrackingEvent = e.TrackingEvent as PlayTimeTrackingEvent;

                var newUrl = url + string.Format("{3}init={0}&ct={1}&last={2}", isStart ? 1 : 0, (int)Math.Round(delta.TotalSeconds), isEnd ? 1 : 0, url.Contains("?") ? "&" : "?");
                AdTracking.Current.FireTracking(newUrl);
            }
        }
 private void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
 {
     if (e.TrackingEvent.Area == TrackingEventArea)
     {
         var eventCallback = e.TrackingEvent.Data as FWEventCallback;
         if (eventCallback != null)
         {
             foreach (var url in eventCallback.GetUrls())
             {
                 TrackVideoViewMarker(url, e);
             }
         }
     }
 }
 private void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
 {
     if (e.TrackingEvent.Area == TrackingEventArea)
     {
         var eventCallback = e.TrackingEvent.Data as FWEventCallback;
         if (eventCallback != null)
         {
             foreach (var url in eventCallback.GetUrls())
             {
                 TrackVideoViewMarker(url, e);
             }
         }
     }
 }
示例#5
0
 void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
 {
     if (e.TrackingEvent.Area == AnalyticsPlugin.TrackingEventArea)
     {
         if (e.TrackingEvent is PositionTrackingEvent)
         {
             var positionTracked = (PositionTrackingEvent)e.TrackingEvent;
             if (positionTracked.PositionPercentage.HasValue)
             {
                 if (PositionPercentageReached != null)
                 {
                     PositionPercentageReached(this, new PositionPercentageReachedEventArgs(positionTracked.PositionPercentage.Value));
                 }
             }
             else
             {
                 if (PositionReached != null)
                 {
                     PositionReached(this, new PositionReachedEventArgs(positionTracked.Position));
                 }
             }
         }
         else if (e.TrackingEvent is PlayTimeTrackingEvent)
         {
             var PlayTimeTracked = (PlayTimeTrackingEvent)e.TrackingEvent;
             if (PlayTimeTracked.PlayTimePercentage.HasValue)
             {
                 if (PlayTimePercentageReached != null)
                 {
                     PlayTimePercentageReached(this, new PlayTimePercentageReachedEventArgs(PlayTimeTracked.PlayTimePercentage.Value));
                 }
             }
             else
             {
                 if (PlayTimeReached != null)
                 {
                     PlayTimeReached(this, new PlayTimeReachedEventArgs(PlayTimeTracked.PlayTime));
                 }
             }
         }
     }
 }
 void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
 {
     var trackedEventList = ResultsEventList.ItemsSource as ObservableCollection<EventTrackedEventArgs>;
     trackedEventList.Add(e);
 }
        void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
        {
            var trackedEventList = ResultsEventList.ItemsSource as ObservableCollection <EventTrackedEventArgs>;

            trackedEventList.Add(e);
        }
 void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
 {
     if (e.TrackingEvent.Area == AnalyticsPlugin.TrackingEventArea)
     {
         if (e.TrackingEvent is PositionTrackingEvent)
         {
             var positionTracked = (PositionTrackingEvent)e.TrackingEvent;
             if (positionTracked.PositionPercentage.HasValue)
             {
                 if (PositionPercentageReached != null) PositionPercentageReached(this, new PositionPercentageReachedEventArgs(positionTracked.PositionPercentage.Value));
             }
             else
             {
                 if (PositionReached != null) PositionReached(this, new PositionReachedEventArgs(positionTracked.Position));
             }
         }
         else if (e.TrackingEvent is PlayTimeTrackingEvent)
         {
             var PlayTimeTracked = (PlayTimeTrackingEvent)e.TrackingEvent;
             if (PlayTimeTracked.PlayTimePercentage.HasValue)
             {
                 if (PlayTimePercentageReached != null) PlayTimePercentageReached(this, new PlayTimePercentageReachedEventArgs(PlayTimeTracked.PlayTimePercentage.Value));
             }
             else
             {
                 if (PlayTimeReached != null) PlayTimeReached(this, new PlayTimeReachedEventArgs(PlayTimeTracked.PlayTime));
             }
         }
     }
 }
 void trackingPlugin_EventTracked(object sender, EventTrackedEventArgs e)
 {
     var trackedEventList = ResultsEventList.ItemsSource as ObservableCollection<EventTrackedEventArgs>;
     trackedEventList.Add(e);
     Debug.WriteLine(string.Format("{1} - tracked: {0}", e.TrackingEvent.Data, e.Timestamp));
 }
        private void TrackVideoViewMarker(string url, EventTrackedEventArgs e)
        {
            if (!trackingEnded)
            {
                bool isStart;
                bool isEnd;
                TimeSpan currentPlayTime;
                if (e.TrackingEvent is PositionTrackingEvent)
                {
                    var playTimeTrackingPlugin = MediaPlayer.Plugins.OfType<PlayTimeTrackingPlugin>().FirstOrDefault();
                    if (playTimeTrackingPlugin == null) throw new Exception("PlayTimeTrackingPlugin not found; required for FreeWheelPlugin");
                    var positionTrackingEvent = (PositionTrackingEvent)e.TrackingEvent;
                    if (!positionTrackingEvent.PositionPercentage.HasValue || positionTrackingEvent.PositionPercentage.Value != 1) throw new Exception("Invalid tracking event was registered for FreeWheelPlugin");
                    isStart = false;
                    isEnd = true;
                    currentPlayTime = playTimeTrackingPlugin.PlayTime;
                    trackingEnded = true; // set this flag to prevent further tracking
                }
                else if (e.TrackingEvent is PlayTimeTrackingEvent)
                {
                    var playTimeTrackingEvent = (PlayTimeTrackingEvent)e.TrackingEvent;
                    isStart = playTimeTrackingEvent.PlayTime == TimeSpan.Zero;
                    isEnd = false;
                    currentPlayTime = playTimeTrackingEvent.PlayTime;
                }
                else
                {
                    throw new ArgumentException();
                }

                TimeSpan delta;
                if (lastTrackingEvent != null)
                {
                    delta = currentPlayTime - lastTrackingEvent.PlayTime;
                }
                else
                {
                    delta = currentPlayTime;
                }
                lastTrackingEvent = e.TrackingEvent as PlayTimeTrackingEvent;

                var newUrl = url + string.Format("{3}init={0}&ct={1}&last={2}", isStart ? 1 : 0, (int)Math.Round(delta.TotalSeconds), isEnd ? 1 : 0, url.Contains("?") ? "&" : "?");
                AdTracking.Current.FireTracking(newUrl);
            }
        }