Beispiel #1
0
        /// <summary>
        /// Creates a HashSet of assets to be included in the user's playlist.
        /// Uses the Channel's ChannelAsset HashSet.
        /// </summary>
        /// <returns>a HashSet of PlayListAsset objects</returns>
        private static HashSet <ContentPlaylistAsset> ConvertChannelAssetsToPlayListAssetsIfDateTimeDemoPermits(Channel channel,
                                                                                                                DemographicRangeVerifier demographicRangeVerifier, DateTime now)
        {
            HashSet <ContentPlaylistAsset> playlistAssets = new HashSet <ContentPlaylistAsset>();

            ContentPlaylistAsset playlistAsset = null;

            foreach (ChannelAsset chAsset in channel.ChannelAssets)
            {
                if (now >= chAsset.StartDateTime && now <= chAsset.EndDateTime &&
                    demographicRangeVerifier.IsAssetDemoSyntaxPlayable(chAsset.DemoRequirements))
                {
                    playlistAsset = new ContentPlaylistAsset
                    {
                        AssetID          = chAsset.AssetID,
                        AssetFilename    = chAsset.AssetFilename,
                        ClickDestination = chAsset.ClickDestination,
                        AssetWebSite     = chAsset.AssetWebSite,
                        DisplayLength    = chAsset.DisplayDuration,
                        PlayerType       = chAsset.PlayerType,
                        ScheduleInfo     = chAsset.ScheduleInfo,
                        AssetLevel       = chAsset.AssetLevel == ChannelDataAssetLevel.Normal ? PlaylistAssetLevel.Normal : PlaylistAssetLevel.Premium,
                        StartDateTime    = chAsset.StartDateTime,
                        EndDateTime      = chAsset.EndDateTime
                    };

                    playlistAssets.Add(playlistAsset);
                }
            }

            return(playlistAssets);
        }
        public void PickRandomContentPlaylistAssetTest1()
        {
            Playlist             playlist       = null;                                              // TODO: Initialize to an appropriate value
            AssetScheduler       assetScheduler = null;                                              // TODO: Initialize to an appropriate value
            PlaylistAssetPicker  target         = new PlaylistAssetPicker(playlist, assetScheduler); // TODO: Initialize to an appropriate value
            ContentPlaylistAsset expected       = null;                                              // TODO: Initialize to an appropriate value
            ContentPlaylistAsset actual;

            actual = target.SelectAsset();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #3
0
        public ChannelAssetAssociation SelectAsset(float totalDisplayTime, float totalAdvertDisplayTime, float protectedContentTime,
                                                   float advertDisplayThreshold, string displayMessage, string appToRun)
        {
            ChannelAssetAssociation channelAssetAssociation = null;

            if (_bErrorOnSetup)
            {
                PlaylistAsset playlistAsset = new ContentPlaylistAsset(_displayMessageAssetDisplayLength, displayMessage, appToRun);

                _logger.WriteError("There was an error on initial setup; \"No Assets\" asset selected.");

                return(new ChannelAssetAssociation(0, playlistAsset));
            }

            // is the next asset content or advert?
            _logger.WriteMessage("Deciding whether the next asset will be a content or an advert.");

            bool bIsNextAssetAdvert = IsNextAssetAdvert(totalDisplayTime, totalAdvertDisplayTime, protectedContentTime, advertDisplayThreshold);

            _logger.WriteMessage("will the next asset be an advert: " + bIsNextAssetAdvert);

            if (bIsNextAssetAdvert)
            {
                channelAssetAssociation = PickRandomAdvertPlaylistAsset();
            }
            else
            {
                channelAssetAssociation = PickRandomContentPlaylistAsset();
            }

            if (bIsNextAssetAdvert && channelAssetAssociation == null)
            {
                _logger.WriteMessage("Next asset is an advert but an advert could not be selected at this time. Attempting to select a content.");

                channelAssetAssociation = PickRandomContentPlaylistAsset();

                if (channelAssetAssociation != null)
                {
                    _logger.WriteMessage("playlist asset " + channelAssetAssociation.PlaylistAsset.AssetID + " was selected.");
                }
            }

            // if no asset was found, create a "No assets" asset
            if (channelAssetAssociation == null)
            {
                channelAssetAssociation = CreateNoAssetsChannelAssetAssociation();

                _logger.WriteMessage("no asset was found, \"No Assets\" asset selected.");
            }

            return(channelAssetAssociation);
        }
        /// <summary>
        /// Shows a content asset on the screensaver and sets the timer to its length
        /// </summary>
        /// <param name="cpp">ContentPlaylistAssetPicker to determine a random content asset to pick</param>
        /// <param name="timer">Timer object to check whether the asset display length has elapsed</param>
        /// <returns>The information on the content playlist asset, null if no available asset found</returns>
        public static ContentPlaylistAsset ShowContentAsset(PlaylistAssetPicker playlistAssetPicker, Timer timer)
        {
            ContentPlaylistAsset cpa = playlistAssetPicker.PickRandomContentPlaylistAsset();

            if (cpa == null)
            {
                return(null);
            }

            timer.Interval = cpa.DisplayLength * 1000; // convert to seconds

            return(cpa);
        }
Beispiel #5
0
        // picks a random content asset from channel bucket
        private ChannelAssetAssociation GetRandomContentPlaylistAsset(ChannelBucket cb)
        {
            // Randomly pick asset from full bucket list
            // check whether selected asset can be played according to temporal scheduling
            // if not pick again. This will be repeated 20 times.
            for (int i = 0; i < 20; i++)
            {
                ContentPlaylistAsset contentPlaylistAsset = GetRandomElement(cb.ContentAssets);

                if (contentPlaylistAsset == null)
                {
                    _logger.WriteMessage("no asset found in this channel bucket.");
                    return(null);
                }

                _logger.WriteMessage("content asset: " + contentPlaylistAsset.AssetID +
                                     " selected randomly. Determining if it can be played at this time.");

                if (_consumedContentPlaylistAssets.Contains(contentPlaylistAsset))
                {
                    continue;
                }

                _logger.WriteMessage("content asset has not been attempted on this run.");

                if (!((contentPlaylistAsset.StartDateTime <= DateTime.Now &&
                       contentPlaylistAsset.EndDateTime >= DateTime.Now
                       &&
                       (contentPlaylistAsset.PlayerType != PlayerType.WebSite ||
                        _bIncludeContentWebAssets && contentPlaylistAsset.PlayerType == PlayerType.WebSite))) ||
                    (!_assetScheduler.IsAssetPlayable(contentPlaylistAsset.ScheduleInfo)))
                {
                    _consumedContentPlaylistAssets.Add(contentPlaylistAsset);
                    continue;
                }



                _logger.WriteMessage("content asset has no schedule info. Checking if it is available.");

                if (contentPlaylistAsset.PlayerType == PlayerType.WebSite)
                {
                    _logger.WriteMessage("content asset is a website. Checking if it is available online.");

                    if (AssetWebsiteExists(contentPlaylistAsset.AssetWebSite))
                    {
                        _logger.WriteMessage("content asset " + contentPlaylistAsset.AssetWebSite +
                                             " is available online and will be selected.");
                        return(new ChannelAssetAssociation(cb.ChannelID, contentPlaylistAsset));
                    }

                    _logger.WriteMessage("content asset " + contentPlaylistAsset.AssetWebSite +
                                         " is not available online. Disabling selection of web content for this run.");
                    _bIncludeContentWebAssets = false;
                }
                else
                {
                    _logger.WriteMessage("content asset is a non-website. Checking if it is available on disk.");

                    if (AssetFileExists(contentPlaylistAsset.GetAssetFilenameGUIDSuffix(),
                                        contentPlaylistAsset.AssetFilename))
                    {
                        _logger.WriteMessage("content asset " + contentPlaylistAsset.AssetFilename +
                                             " exists on disk.");

                        if (!_bInsufficientMemoryForLargeFiles || IsNonLargeFile(contentPlaylistAsset))
                        {
                            _logger.WriteTimestampedMessage("Content asset " + contentPlaylistAsset.AssetFilename +
                                                            " can be played.");
                            return(new ChannelAssetAssociation(cb.ChannelID, contentPlaylistAsset));
                        }

                        _logger.WriteTimestampedMessage(
                            "There are physical memory restrictions and content asset " +
                            contentPlaylistAsset.AssetFilename + " cannot be played");
                    }
                    else
                    {
                        _logger.WriteMessage("content asset " + contentPlaylistAsset.AssetFilename +
                                             " does not exist on disk.");
                    }
                }


                _consumedContentPlaylistAssets.Add(contentPlaylistAsset);
            }

            // if nothing found go through Channel Bucket's entire list (excluding the consumed ones),
            // checking what CAN be displayed and create a shortlist
            // then randomly pick one from the shortlist.
            ContentPlaylistAsset cpa = GetRandomElement(GetPlayableContentPlaylistAssetsExcludingConsumed(cb));

            if (cpa == null)
            {
                return(null);
            }

            return(new ChannelAssetAssociation(cb.ChannelID, cpa));
        }