Exemple #1
0
        /// <summary>
        /// Creates a new instance of VpaidImageAdPlayer.
        /// </summary>
        /// <param name="skippableOffset">The position in the ad at which the ad can be skipped. If null, the ad cannot be skipped.</param>
        /// <param name="suggestedDuration">The duration of the ad. If not specified, the ad is closed when the next ad is played.</param>
        /// <param name="clickThru">The Uri to navigate to when the ad is clicked or tapped. Can be null of no action should take place.</param>
        public VpaidImageAdPlayer(FlexibleOffset skippableOffset, TimeSpan?suggestedDuration, Uri clickThru)
        {
            IsHitTestVisible = false;
            image            = new Image();
            Background       = new SolidColorBrush(Colors.Transparent);
            image.Stretch    = Stretch.None;
            Opacity          = 0;
            State            = AdState.None;
            AdLinear         = false;

            SkippableOffset   = skippableOffset;
            SuggestedDuration = suggestedDuration;
            ClickThru         = clickThru;
            this.NavigateUri  = ClickThru;
        }
        /// <summary>
        /// Creates a new instance of VpaidVideoAdPlayer.
        /// </summary>
        /// <param name="skippableOffset">The position in the ad at which the ad can be skipped. If null, the ad cannot be skipped.</param>
        /// <param name="maxDuration">The max duration of the ad. If not specified, the length of the video is assumed.</param>
        /// <param name="clickThru">The Uri to navigate to when the ad is clicked or tapped. Can be null of no action should take place.</param>
        public VpaidVideoAdPlayer(FlexibleOffset skippableOffset, TimeSpan?maxDuration, Uri clickThru)
        {
            IsHitTestVisible = false;
            mediaElement     = new MediaElement();
            Background       = new SolidColorBrush(Colors.Black);
#if !WINDOWS80
            Opacity = 0.01; // HACK: Win8.1 won't load the video if opacity = 0
#else
            Opacity = 0;
#endif
            State    = AdState.None;
            AdLinear = true;

            SkippableOffset  = skippableOffset;
            MaxDuration      = maxDuration;
            this.NavigateUri = clickThru;
        }
        private void CreateAdvertisement(VmapAdBreak adBreak)
        {
            Advertisement ad = null;

            switch (adBreak.TimeOffset)
            {
            case "start":
                ad = new PrerollAdvertisement();
                break;

            case "end":
                ad = new PostrollAdvertisement();
                break;

            default:
                var offset = FlexibleOffset.Parse(adBreak.TimeOffset);
                if (offset != null)
                {
                    var midroll = new MidrollAdvertisement();
                    if (!offset.IsAbsolute)
                    {
                        midroll.TimePercentage = offset.RelativeOffset;
                    }
                    else
                    {
                        midroll.Time = offset.AbsoluteOffset;
                    }
                    ad = midroll;
                }
                break;
            }

            if (ad != null)
            {
                ad.Source = GetAdSource(adBreak.AdSource);
                if (ad.Source != null)
                {
                    Advertisements.Add(ad);
                    adBreaks.Add(ad, adBreak);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Creates a new instance of VpaidImageAdPlayer.
        /// </summary>
        /// <param name="skippableOffset">The position in the ad at which the ad can be skipped. If null, the ad cannot be skipped.</param>
        /// <param name="suggestedDuration">The duration of the ad. If not specified, the ad is closed when the next ad is played.</param>
        /// <param name="clickThru">The Uri to navigate to when the ad is clicked or tapped. Can be null of no action should take place.</param>
        /// <param name="dimensions">The dimensions of the ad.</param>
        public VpaidWebAdPlayer(FlexibleOffset skippableOffset, TimeSpan?suggestedDuration, Uri clickThru, Size dimensions)
        {
            IsHitTestVisible = false;
#if WINDOWS_PHONE
            WebView = new Phone.Controls.WebBrowser();
#elif SILVERLIGHT
            WebView = new WebBrowser();
#else
            WebView = new WebView();
#endif
            WebView.Visibility = Visibility.Collapsed;
            Background         = new SolidColorBrush(Colors.Transparent);
            State             = AdState.None;
            AdLinear          = false;
            InitialDimensions = dimensions;

            SkippableOffset   = skippableOffset;
            SuggestedDuration = suggestedDuration;
            ClickThru         = clickThru;
            this.NavigateUri  = ClickThru;
        }
Exemple #5
0
 /// <summary>
 /// Creates a new instance of VpaidIFrameAdPlayer.
 /// </summary>
 /// <param name="skippableOffset">The position in the ad at which the ad can be skipped. If null, the ad cannot be skipped.</param>
 /// <param name="suggestedDuration">The suggested duration of the ad.</param>
 /// <param name="clickThru">The Uri to navigate to when the ad is clicked or tapped. Can be null of no action should take place.</param>
 /// <param name="dimensions">The dimensions of the ad.</param>
 public VpaidIFrameAdPlayer(FlexibleOffset skippableOffset, TimeSpan?suggestedDuration, Uri clickThru, Size dimensions)
     : base(skippableOffset, suggestedDuration, clickThru, dimensions)
 {
 }