async void pf_MarkerReached(object sender, TimelineMarkerRoutedEventArgs e) { if (e.Marker.Type == "myAd") { var adSource = new RemoteAdSource() { Type = VastAdPayloadHandler.AdType, Uri = new Uri("http://smf.blob.core.windows.net/samples/win8/ads/vast_linear.xml") }; //var adSource = new AdSource() { Type = DocumentAdPayloadHandler.AdType, Payload = SampleAdDocument }; var progress = new Progress<AdStatus>(); try { await player.PlayAd(adSource, progress, CancellationToken.None); } catch { /* ignore */ } } }
async void pf_MarkerReached(object sender, TimelineMarkerRoutedEventArgs e) { if (e.Marker.Type == "myAd") { var adSource = new RemoteAdSource() { Type = VastAdPayloadHandler.AdType, Uri = new Uri("http://smf.blob.core.windows.net/samples/win8/ads/vast_linear.xml") }; //var adSource = new AdSource() { Type = DocumentAdPayloadHandler.AdType, Payload = SampleAdDocument }; var progress = new Progress <AdStatus>(); try { await player.PlayAd(adSource, progress, CancellationToken.None); } catch { /* ignore */ } } }
/// <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; }