/// <summary>
        /// Creates an IAdSource from a VMAP AdSource (required for the AdHandlerPlugin to play the ad).
        /// </summary>
        /// <param name="source">The VMAP AdSource object</param>
        /// <returns>An IAdSource object that can be played by the AdHandlerPlugin. Returns null if insufficient data is available.</returns>
        public static IAdSource GetAdSource(VmapAdSource source)
        {
            IAdSource result = null;

            if (!string.IsNullOrEmpty(source.VastData))
            {
                result = new AdSource(source.VastData, VastAdPayloadHandler.AdType);
            }
            else if (!string.IsNullOrEmpty(source.CustomAdData))
            {
                result = new AdSource(source.CustomAdData, source.CustomAdDataTemplateType);
            }
            else if (source.AdTag != null)
            {
                result = new RemoteAdSource(source.AdTag, source.AdTagTemplateType);
            }

            if (result != null)
            {
                result.AllowMultipleAds = source.AllowMultipleAds;
                result.MaxRedirectDepth = source.FollowsRedirect ? new int?() : 0;
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Plays a simple linear clip
        /// </summary>
        /// <param name="mediaPlayer">The MediaPlayer instance to play the clip in.</param>
        /// <param name="clipSource">The source Uri of the clip.</param>
        /// <param name="progress">An object that allows progress to be reported.</param>
        /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
        /// <returns>An awaitable task that returns true if the clip was played.</returns>
        public static Task <bool> PlayLinearClip(this MediaPlayer mediaPlayer, Uri clipSource, IProgress <AdStatus> progress, CancellationToken cancellationToken)
        {
            var adSource = new AdSource(clipSource, ClipAdPayloadHandler.AdType);

            return(mediaPlayer.PlayAd(adSource, progress, cancellationToken));
        }
        /// <summary>
        /// Creates an IAdSource from a VMAP AdSource (required for the AdHandlerPlugin to play the ad).
        /// </summary>
        /// <param name="source">The VMAP AdSource object</param>
        /// <returns>An IAdSource object that can be played by the AdHandlerPlugin. Returns null if insufficient data is available.</returns>
        public static IAdSource GetAdSource(VmapAdSource source)
        {
            IAdSource result = null;
            if (!string.IsNullOrEmpty(source.VastData))
            {
                result = new AdSource(source.VastData, VastAdPayloadHandler.AdType);
            }
            else if (!string.IsNullOrEmpty(source.CustomAdData))
            {
                result = new AdSource(source.CustomAdData, source.CustomAdDataTemplateType);
            }
            else if (source.AdTag != null)
            {
                result = new RemoteAdSource(source.AdTag, source.AdTagTemplateType);
            }

            if (result != null)
            {
                result.AllowMultipleAds = source.AllowMultipleAds;
                result.MaxRedirectDepth = source.FollowsRedirect ? new int?() : 0;
            }

            return result;
        }