void IPlayer.RemoveScheduledAd(ScheduledAd ScheduledAd) { this.RemoveScheduledAd(ScheduledAd); }
/// <summary> /// Removes a scheduled ad created by scheduling an ad trigger /// </summary> /// <param name="ScheduledAd"></param> public void RemoveScheduledAd(ScheduledAd ScheduledAd) { var marker = AdMarkers.FirstOrDefault(m => m.ScheduledAd == ScheduledAd); if (marker != null) { AdMarkers.Remove(marker); } }
private void CleanupScheduledAd(ScheduledAd scheduledAd) { scheduledAd.Deactivated -= scheduledAd_Deactivated; ScheduledAds.Remove(scheduledAd); player.IfNotNull(p => p.RemoveScheduledAd(scheduledAd)); }
/// <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; }