| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using DCL.Controllers; |
| | 5 | | using DCL.Helpers; |
| | 6 | | using DCL.Models; |
| | 7 | |
|
| | 8 | | namespace DCL.Components |
| | 9 | | { |
| | 10 | | public class DCLVideoClip : BaseDisposable |
| | 11 | | { |
| | 12 | | [System.Serializable] |
| | 13 | | public class Model : BaseModel |
| | 14 | | { |
| | 15 | | public string url; |
| | 16 | |
|
| 15 | 17 | | public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); } |
| | 18 | | } |
| | 19 | |
|
| 0 | 20 | | public bool isExternalURL { get; private set; } |
| 0 | 21 | | public bool isStream { get; private set; } |
| | 22 | |
|
| 45 | 23 | | public DCLVideoClip() { model = new Model(); } |
| | 24 | |
|
| 0 | 25 | | public override int GetClassId() { return (int) CLASS_ID.VIDEO_CLIP; } |
| | 26 | |
|
| | 27 | | public override IEnumerator ApplyChanges(BaseModel newModel) |
| | 28 | | { |
| 15 | 29 | | Model model = (Model) newModel; |
| 15 | 30 | | isExternalURL = model.url.StartsWith("http://") || model.url.StartsWith("https://"); |
| 75 | 31 | | isStream = !new[] { ".mp4", ".ogg", ".mov", ".webm" }.Any(x => model.url.EndsWith(x)); |
| 15 | 32 | | yield break; |
| | 33 | | } |
| | 34 | |
|
| | 35 | | public string GetUrl() |
| | 36 | | { |
| 15 | 37 | | Model model = (Model) this.model; |
| | 38 | |
|
| 15 | 39 | | string contentsUrl = model.url; |
| | 40 | |
|
| 15 | 41 | | if (!isExternalURL) |
| | 42 | | { |
| 0 | 43 | | scene.contentProvider.TryGetContentsUrl(model.url, out contentsUrl); |
| | 44 | | } |
| | 45 | |
|
| 15 | 46 | | return contentsUrl; |
| | 47 | | } |
| | 48 | | } |
| | 49 | | } |