private void adHost_FullScreenChanged(object sender, EventArgs e)
 {
     if (adHost.IsFullScreen)
     {
         VpaidController.OnFullscreen();
     }
 }
        public virtual void Load()
        {
            try
            {
                VpaidController = new VpaidController();

                VpaidController.AdIsLinear     += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdIsLinear);
                VpaidController.AdIsNotLinear  += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdIsNotLinear);
                VpaidController.Log            += new EventHandler <ActiveCreativeLogEventArgs>(vPaidController_Log);
                VpaidController.TrackingFailed += new EventHandler <VpaidController.TrackingFailureEventArgs>(vPaidController_TrackingFailed);
                VpaidController.AdLoaded       += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdLoaded);
                VpaidController.AdStopped      += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdStopped);
                VpaidController.AdStarted      += new EventHandler <ActiveCreativeEventArgs>(VpaidController_AdStarted);
                // Note: all 3 events can use the same handler
                VpaidController.AdFailed      += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdFailed);
                VpaidController.AdLoadFailed  += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdFailed);
                VpaidController.AdStartFailed += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdFailed);

                VpaidController.AdRemoved         += new EventHandler <ActiveCreativeEventArgs>(vPaidController_AdCompleted);
                VpaidController.AdProgressChanged += new EventHandler <ActiveCreativeEventArgs>(VpaidController_AdProgressChanged);
                VpaidController.AdPaused          += new EventHandler <ActiveCreativeEventArgs>(VpaidController_AdPaused);
                VpaidController.AdResumed         += new EventHandler <ActiveCreativeEventArgs>(VpaidController_AdResumed);

                isLoaded = true;
                PluginLoaded.IfNotNull(i => i(this));
            }
            catch (Exception e)
            {
                PluginLoadFailed.IfNotNull(i => i(this, e));
            }
        }
        protected void CancelCreative(ActiveCreative creative)
        {
            VpaidController.RemoveAd(creative);

            if (CreativeCanceled != null)
            {
                CreativeCanceled(this, new CreativeEventArgs(creative.Source));
            }
        }
        protected virtual void AdStopped(ActiveCreativeEventArgs e)
        {
            VpaidController.RemoveAd(e.ActiveCreative);

            if (CreativeSucceeded != null)
            {
                CreativeSucceeded(this, new CreativeEventArgs(e.ActiveCreative.Source));
            }
        }
        internal protected ActiveCreative GetCreative(ICreativeSource adSource, IAdTarget adTarget)
        {
            IVpaid adPlayer;
            var    vPaidFactories = GetVpaidFactories().ToList();

            do
            {
                var rankedVpaidFactories =
                    from factory in vPaidFactories
                    let rank = factory.CheckSupport(adSource, adTarget)
                               where rank > PriorityCriteriaEnum.NotSupported
                               orderby rank descending
                               select factory;

                var playerFactory = rankedVpaidFactories.FirstOrDefault();
                if (playerFactory == null)
                {
                    return(null);
                }

                adPlayer = playerFactory.GetVpaidPlayer(adSource, adTarget);

                // handshake with the ad player to make sure the version of VAST is OK
                if (adPlayer == null || !VpaidController.Handshake(adPlayer))
                {
                    // the version is no good, remove the factory from the list and try again.
                    vPaidFactories.Remove(playerFactory);
                    if (!vPaidFactories.Any())
                    {
                        return(null);
                    }
                    adPlayer = null;
                }
            } while (adPlayer == null);

            //put companion in target
            if (!adTarget.AddChild(adPlayer))
            {
                return(null);
            }

            return(new ActiveCreative(adPlayer, adSource, adTarget));
        }
        public virtual void Load()
        {
            try
            {
                VpaidController = new VpaidController();

                VpaidController.AdIsLinear += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdIsLinear);
                VpaidController.AdIsNotLinear += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdIsNotLinear);
                VpaidController.Log += new EventHandler<ActiveCreativeLogEventArgs>(vPaidController_Log);
                VpaidController.TrackingFailed += new EventHandler<VpaidController.TrackingFailureEventArgs>(vPaidController_TrackingFailed);
                VpaidController.AdLoaded += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdLoaded);
                VpaidController.AdStopped += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdStopped);
                VpaidController.AdStarted += new EventHandler<ActiveCreativeEventArgs>(VpaidController_AdStarted);
                // Note: all 3 events can use the same handler
                VpaidController.AdFailed += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdFailed);
                VpaidController.AdLoadFailed += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdFailed);
                VpaidController.AdStartFailed += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdFailed);

                VpaidController.AdRemoved += new EventHandler<ActiveCreativeEventArgs>(vPaidController_AdCompleted);
                VpaidController.AdProgressChanged += new EventHandler<ActiveCreativeEventArgs>(VpaidController_AdProgressChanged);
                VpaidController.AdPaused += new EventHandler<ActiveCreativeEventArgs>(VpaidController_AdPaused);
                VpaidController.AdResumed += new EventHandler<ActiveCreativeEventArgs>(VpaidController_AdResumed);

                isLoaded = true;
                PluginLoaded.IfNotNull(i => i(this));
            }
            catch (Exception e)
            {
                PluginLoadFailed.IfNotNull(i => i(this, e));
            }
        }
 private void vPaidController_TrackingFailed(object sender, VpaidController.TrackingFailureEventArgs e)
 {
     SendLogEntry(LogEntryTypes.TrackingFailed, LogLevel.Error, string.Format(VpaidResources.TrackingFailed, e.TrackingEvent, e.Exception.Message));
 }
 private void adHost_VolumeChanged(object sender, EventArgs e)
 {
     VpaidController.SetVolume(adHost.Volume);
 }
 protected void PlayCreative(ActiveCreative creative, object userState)
 {
     VpaidController.LoadAd(creative, (int)(adHost.PlaybackBitrate / 1024), userState);
     RefreshAdMode();
 }
 protected virtual void vPaidController_AdLoaded(object sender, ActiveCreativeEventArgs e)
 {
     VpaidController.SetVolume(e.ActiveCreative, adHost.Volume);
     VpaidController.StartAd(e.ActiveCreative, e.UserState);
 }