62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Crosstales.Radio.Model;
|
|
using Crosstales.Radio.Model.Entry;
|
|
using Crosstales.Radio.Model.Enum;
|
|
using UnityEngine;
|
|
|
|
namespace Crosstales.Radio.Provider
|
|
{
|
|
[HelpURLAttribute("https://www.crosstales.com/media/data/assets/radio/api/class_crosstales_1_1_radio_1_1_provider_1_1_radio_provider_u_r_l.html")]
|
|
public class RadioProviderURL : BaseRadioProvider
|
|
{
|
|
[Tooltip("All source radio station entries.")]
|
|
[Header("Source Settings")]
|
|
public List<RadioEntryURL> Entries = new List<RadioEntryURL>();
|
|
|
|
public override List<BaseRadioEntry> RadioEntries
|
|
{
|
|
get
|
|
{
|
|
return Entries.Cast<BaseRadioEntry>().ToList();
|
|
}
|
|
}
|
|
|
|
protected override void init()
|
|
{
|
|
base.init();
|
|
foreach (RadioEntryURL entry in Entries)
|
|
{
|
|
if (entry == null || !entry.EnableSource)
|
|
{
|
|
continue;
|
|
}
|
|
if (!string.IsNullOrEmpty(entry.FinalURL))
|
|
{
|
|
if (entry.DataFormat == DataFormatURL.Stream)
|
|
{
|
|
RadioStation item = new RadioStation(entry.Name, entry.FinalURL, entry.Format, entry.Station, entry.Genres.ToLower(), entry.Bitrate, entry.Rating, entry.Description, entry.Icon, entry.ChunkSize, entry.BufferSize, entry.ExcludedCodec);
|
|
if (!base.Stations.Contains(item))
|
|
{
|
|
base.Stations.Add(item);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning(string.Concat("Station already added: '", entry, "'"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
StartCoroutine(loadWeb(addCoRoutine(), entry));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning(string.Concat(entry, ": 'URL' is null or empty!", Environment.NewLine, "Please add a valid URL."));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|