Esempio n. 1
0
        /// <summary>
        /// Start watching the given medium. Only if a medium with type Web is given, is it goint to be watched.
        /// </summary>
        /// <param name="medium">The Medium to watch</param>
        public bool Watch(Medium medium)
        {
            // Do nothing if we already have a web medium
            if (medium != Medium.Web || _webMedium != null)
            {
                return(false);
            }
            _webMedium = medium;

            // Set container
            _container = new RadioChannels(_containerName, _webMedium, true);

            // Start timer for fetching channels
            this.StartFetching();

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Builds the contents object
        /// </summary>
        /// <param name="channels">The channels source</param>
        /// <param name="filter">The filter object which contains the parameters with which to query for items</param>
        /// <param name="channelsContainer">The radio channels container the tracks are sources from</param>
        /// <returns>A filled contents object</returns>
        Contents BuildContents(IEnumerable <RadioChannel> channels, Options filter, RadioChannels channelsContainer)
        {
            // Create contents instance
            var contents = new Contents(channelsContainer);

            var type = (filter.ContainsKey("type") ? filter["type"] : channelsContainer.ViewTypes.FirstOrDefault()) ?? Types.Channel;

            // Get the data for the given type
            switch (type)
            {
            case Types.Channel:
                contents.Data = GetChannelsData(channels);
                contents.Keys = new string[] { "id", "name", "index" };
                break;

            case Types.Genre:
                contents.Data = GetGenresData(channels);
                contents.Keys = new string[] { "genre", "index" };
                break;
            }

            return(contents);
        }
        /// <summary>
        /// Builds the contents object
        /// </summary>
        /// <param name="channels">The channels source</param>
        /// <param name="filter">The filter object which contains the parameters with which to query for items</param>
        /// <param name="channelsContainer">The radio channels container the tracks are sources from</param>
        /// <returns>A filled contents object</returns>
        Contents BuildContents(IEnumerable<RadioChannel> channels, Options filter, RadioChannels channelsContainer)
        {
            // Create contents instance
            var contents = new Contents(channelsContainer);

            var type = (filter.ContainsKey("type") ? filter["type"] : channelsContainer.ViewTypes.FirstOrDefault()) ?? Types.Channel;

            // Set meta data
            dynamic meta = new ExpandoObject();
            contents.Meta = meta;
            meta.SortedByAlpha = true;

            // Get the data for the given type
            switch (type) {
                case Types.Channel:
                    contents.Data = GetChannelsData(channels);
                    contents.Keys = new string[] { "id", "name", "index" };
                    break;
                case Types.Genre:
                    contents.Data = GetGenresData(channels);
                    contents.Keys = new string[] { "genre", "index" };
                    break;
            }

            return contents;
        }
        /// <summary>
        /// Start watching the given medium. Only if a medium with type Local is given, is ListenLive going to be watched.
        /// </summary>
        /// <param name="medium">The Medium to watch</param>
        public bool Watch(Medium medium)
        {
            // Do nothing if we already have a local medium
            if (medium.Type != MediumType.Web || _radioMedium != null) return false;
            _radioMedium = medium;

            // Set container
            _container = new RadioChannels(_containerName, _radioMedium, true);

            // Start timer for fetching channels
            this.StartFetching();

            return true;
        }