This project is read-only.

PrerollAdvertisement Issue(Code behind)

Topics: Windows 8 Xaml
Nov 15, 2013 at 3:03 AM
Edited Nov 15, 2013 at 3:47 AM
Got issue regarding the PrerollAdvertisement in the player framwork. Basically I have playlist which plays 20 videos. I need to play PrerollAdvertisement befor the each video. I have programed and add to the adScheduler. My issue is, it's only play PrerollAdvertisement for the first media and after that it's not playing any advertisement. I need to do same with the midroll advertisement as well. I have programed in code behind before the media play. Could you plese direct me into tutorial or sample would be helpful.
       private async void playInitialAd(string adCallUrl)
            AdSchedulerPlugin adScheduler = null;
            adScheduler = this.GetAdSchedulerPlugin();

                var preRollAdvertisement = new PrerollAdvertisement
                    Source = new RemoteAdSource
                        Type = VastAdPayloadHandler.AdType,
                        Uri = new Uri(adCallUrl)

                // Add it to the scheduler
                if (adScheduler != null)

            catch(Exception ex)
                //TODO implements the exceptions
                ex = null;
Same code bit works fine with the
Player Framework for Windows 8 and WP8 (v1.2)

Dec 4, 2013 at 8:15 PM
Instead of adding to the Advertisements collection on the AdSchedulerPlugin, you can use the attached property on each PlaylistItem to hold their own ads. For example, you can call:
AdScheduler.SetAdvertisements(playlistItem1, myAdsForItem1);
AdScheduler.SetAdvertisements(playlistItem2, myAdsForItem2);
(where myAdsForItemX are of type AdvertisementsCollection)