private void Mainsail_ActivateTrigger(object sender, TriggerEventArgs e)
        {
            var t = e.Trigger;

            var marker = new AdMarker();
            marker.Id = t.Id;
            marker.Immediate = true;    // Being will get set automatically for us by setting Immediate to true
            marker.Begin = TimeSpan.Zero;
            marker.End = TimeSpan.FromDays(1);
            marker.Type = "Ad";
            marker.ScheduledAd = new ScheduledAd(t);
            marker.ScheduledAd.Deactivated += new EventHandler(AdMarkerContent_Deactivated);

            activeTriggers.Add(t, marker);

            this.NewMarkers(this, new[] { marker });

            SendLogEntry(LogEntryTypes.TriggerActivated, LogLevel.Information, string.Format(MastMarkerProviderResources.TriggerActivated, t.Id, t.Description));
        }
        /// <summary>
        /// Schedules an ad that is to be handled by an AdPayloadHandlerPlugin.
        /// A valid AdPayloadHandlerPlugin must be part of your application or this will not be handled.
        /// </summary>
        /// <param name="adTrigger">An object containing information about the ad source and target</param>
        /// <param name="startTime">The position within the media where this ad should be played. If ommited ad will begin playing immediately.</param>
        /// <returns>An object that contains information about the scheduled ad.</returns>
        public ScheduledAd ScheduleAdTrigger(IAdSequencingTrigger adTrigger, TimeSpan? startTime = null)
        {
            var adStartTime = startTime.GetValueOrDefault(RelativeMediaPluginPosition);

            var result = new ScheduledAd(adTrigger);
            var adMarker = new AdMarker()
            {
                Immediate = !startTime.HasValue,
                Begin = adStartTime,
                Id = Guid.NewGuid().ToString(),
                ScheduledAd = result,
                End = adStartTime.Add(adTrigger.Duration.GetValueOrDefault(TimeSpan.FromDays(1)))    // update the end based on the duration
            };

            // Immediate == true will trigger the timeline marker immediately instead of waiting for polling to occur
            if (adMarker.Immediate)
            {
                var duration = adMarker.Duration;
                adMarker.Begin = RelativeMediaPluginPosition;
                adMarker.End = adMarker.Begin.Add(duration);    // update the end based on the duration
                AdMarkers.Add(adMarker);
                // force a check on the postions, we know there is one that needs to be fired
                if (!isSeekActive) _adMarkerManager.CheckMarkerPositions(RelativeMediaPluginPosition, AdMarkers, seekInProgress);
            }
            else
            {
                AdMarkers.Add(adMarker);
            }

            return result;
        }
Exemple #3
0
 public AdMarkerEventArgs(AdMarker AdMarker)
 {
     adMarker = AdMarker;
 }
 private void AdManager_MarkerLeft(MediaMarkerManager<AdMarker> markerManager, AdMarker mediaMarker)
 {
     OnAdMarkerLeft(mediaMarker);
 }
 private void AdManager_MarkerReached(MediaMarkerManager<AdMarker> markerManager, AdMarker mediaMarker, bool seekedInto)
 {
     OnAdMarkerReached(mediaMarker, seekedInto);
 }
 private void AdManager_MarkerSkipped(MediaMarkerManager<AdMarker> markerManager, AdMarker mediaMarker)
 {
     OnAdMarkerSkipped(mediaMarker);
 }
        /// <summary>
        /// Raises the AdMarkerSkipped event.
        /// </summary>
        protected virtual void OnAdMarkerSkipped(AdMarker mediaMarker)
        {
            try
            {
                string message = string.Format(SilverlightMediaFrameworkResources.MarkerSkippedLogMessage,
                                               mediaMarker.Type, mediaMarker.Begin, mediaMarker.End);
                SendLogEntry(message: message, type: KnownLogEntryTypes.MarkerSkipped);

                AdMarkerSkipped.IfNotNull(i => i(this, new AdMarkerEventArgs(mediaMarker)));
            }
            catch (Exception err)
            {
                string message = string.Format(SilverlightMediaFrameworkResources.GenericErrorOccurredLogMessage,
                                               "OnAdMarkerSkipped", err.Message);
                SendLogEntry(KnownLogEntryTypes.GeneralErrorOccurred, LogLevel.Error, message);
            }
        }
        /// <summary>
        /// Raises the AdMarkerReached event.
        /// </summary>
        protected virtual void OnAdMarkerReached(AdMarker mediaMarker, bool seekedInto)
        {
            try
            {
                string message = string.Format(SilverlightMediaFrameworkResources.MarkerReachedLogMessage,
                                               mediaMarker.Type, mediaMarker.Begin, mediaMarker.End);
                SendLogEntry(message: message, type: KnownLogEntryTypes.MarkerReached);

                if (mediaMarker.Type == KnownMarkerTypes.Title)
                {
                    MediaTitleContent = mediaMarker.Content;
                }

                AdMarkerReached.IfNotNull(i => i(this, new AdMarkerReachedInfoEventArgs() { Marker = mediaMarker, SeekedInto = seekedInto }));
            }
            catch (Exception err)
            {
                string message = string.Format(SilverlightMediaFrameworkResources.GenericErrorOccurredLogMessage,
                                               "OnAdMarkerReached", err.Message);
                SendLogEntry(KnownLogEntryTypes.GeneralErrorOccurred, LogLevel.Error, message);
            }
        }