using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UMP.Services.Youtube; using UnityEngine; namespace UMP.Services { public class VideoServices { private MonoBehaviour _monoObject; private List _services; private IEnumerator _getVideosEnum; public VideoServices(MonoBehaviour monoObject) { _monoObject = monoObject; _services = new List(); _services.Add(YoutubeService.Default); } public bool ValidUrl(string url) { var isValid = false; foreach (var service in _services) { if (service.ValidUrl(url)) { isValid = true; break; } } return isValid; } public IEnumerator GetVideos(string url, Action> resultCallback, Action errorCallback) { foreach (var service in _services) { if (service.ValidUrl(url)) { _getVideosEnum = service.GetAllVideos(url, resultCallback, errorCallback); yield return _monoObject.StartCoroutine(_getVideosEnum); } } } public static Video FindVideo(List