/// <summary>
 /// Constructs a dynamic <see cref="MediaItem"/> that contains the URL for the given <paramref name="stream"/> and starts the playback.
 /// </summary>
 /// <param name="stream">Stream.</param>
 public static void PlayStream(MyStream stream)
 {
     var mediaItem = CreateStreamMediaItem(stream);
       if (ServiceRegistration.Get<IPlayerContextManager>().IsVideoContextActive)
       {
     PlayItemsModel.CheckQueryPlayAction(mediaItem);
       }
       else
       {
     PlayItemsModel.PlayItem(mediaItem);
       }
 }
        public void ImportAllFavorits(MyStream stream)
        {
            AllFavoritItems.Clear();

              foreach (FavoriteSetupInfo f in FavoritList)
              {
            var item = new ListItem();
            item.AdditionalProperties[NAME] = f.Titel;
            item.SetLabel("Name", f.Titel);
            item.Selected = f.StreamUrls.Contains(stream.StreamUrls[0].StreamUrl);
            AllFavoritItems.Add(item);
              }
              AllFavoritItems.FireChange();
        }
        /// <summary>
        /// Constructs a dynamic <see cref="MediaItem"/> that contains the URL for the given <paramref name="stream"/>.
        /// </summary>
        /// <param name="stream">Stream.</param>
        private static MediaItem CreateStreamMediaItem(MyStream stream)
        {
            IDictionary<Guid, IList<MediaItemAspect>> aspects = new Dictionary<Guid, IList<MediaItemAspect>>();

              MultipleMediaItemAspect providerResourceAspect = MediaItemAspect.CreateAspect(aspects, ProviderResourceAspect.Metadata);
              SingleMediaItemAspect mediaAspect = MediaItemAspect.GetOrCreateAspect(aspects, MediaAspect.Metadata);
              SingleMediaItemAspect audioAspect = MediaItemAspect.GetOrCreateAspect(aspects, AudioAspect.Metadata);

              providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_PRIMARY, true);
              providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, RawUrlResourceProvider.ToProviderResourcePath(stream.StreamUrls[0].StreamUrl).Serialize());
              providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, ServiceRegistration.Get<ISystemResolver>().LocalSystemId);
              providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_MIME_TYPE, WEBRADIO_MIMETYPE);

              mediaAspect.SetAttribute(MediaAspect.ATTR_TITLE, stream.Title);

              MediaItemAspect.SetAttribute(aspects, ThumbnailLargeAspect.ATTR_THUMBNAIL, ImageFromLogo(stream.Logo));

              var mediaItem = new MediaItem(Guid.Empty, aspects);
              return mediaItem;
        }
Esempio n. 4
0
 /// <summary>
 /// Play the Stream with the current StreamID and Set the Playcount +1
 /// </summary>
 private void Play(MyStream ms)
 {
     CurrentStreamLogo = SetStreamLogo(ms);
     WebRadioPlayerHelper.PlayStream(ms);
     StreamListeners.Listeners();
 }
Esempio n. 5
0
 /// <summary>
 /// Get the selected Stream
 /// </summary>
 public void SelectStream(ListItem item)
 {
     SelectedStream = GetStream((string)item.AdditionalProperties[STREAM_URL]);
     Play(SelectedStream);
 }
Esempio n. 6
0
 /// <summary>
 /// Set the Logo of a Stream or use the DefaultLogo
 /// </summary>
 public static string SetStreamLogo(MyStream ms)
 {
     var s = "DefaultLogo.png";
     if (ms.Logo != "")
     {
         s = ms.Logo;
     }
     return s;
 }
Esempio n. 7
0
        /// <summary>
        /// Set the Description by Language
        /// </summary>
        public static string SetStreamDescription(MyStream ms)
        {
            var desc = "";
            var localization = ServiceRegistration.Get<ILocalization>().CurrentCulture.Name.Substring(0, 2);

            // is the original language available
            foreach (var d in ms.Descriptions)
            {
                if (d.Languagecode.Contains(localization))
                {
                    return d.Txt;
                }
            }

            // is English available
            foreach (var d in ms.Descriptions)
            {
                if (d.Languagecode.Contains("en") & d.Txt != "")
                {
                    return d.Txt;
                }
            }

            // is any language available
            foreach (var d in ms.Descriptions)
            {
                if (d.Txt != "")
                {
                    return d.Txt;
                }
            }

            return desc;
        }
Esempio n. 8
0
 /// <summary>
 /// Set the FallbackValues of the current Stream
 /// </summary>
 public static void SetFallbackValues(MyStream ms)
 {
     if (ms.Country == "")
     {
         ms.Country = "unknown";
     }
     if (ms.City == "")
     {
         ms.City = "unknown";
     }
     if (ms.StreamUrls[0].Bitrate == "")
     {
         ms.StreamUrls[0].Bitrate = "unknown";
     }
     if (ms.Genres == "")
     {
         ms.Genres = "unknown";
     }
 }