From 104d4edeb5c0874412b0e91d0cb3c768995a0ce1 Mon Sep 17 00:00:00 2001 From: RblSb Date: Fri, 1 May 2020 10:11:40 +0300 Subject: Support youtube streams --- src/client/Main.hx | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'src/client/Main.hx') diff --git a/src/client/Main.hx b/src/client/Main.hx index 3400595..900f841 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -250,7 +250,7 @@ class Main { author: personal.name, duration: data.duration, isTemp: isTemp, - isIframe: false + isIframe: data.isIframe == true }, atEnd: atEnd }}); @@ -263,23 +263,31 @@ class Main { final iframe = iframeCode.value; if (iframe.length == 0) return; iframeCode.value = ""; - final mediaName:InputElement = cast ge("#customembed-title"); - final name = mediaName.value.length == 0 ? "Custom Media" : mediaName.value; - mediaName.value = ""; + final mediaTitle:InputElement = cast ge("#customembed-title"); + final title = mediaTitle.value; + mediaTitle.value = ""; final checkbox:InputElement = cast ge("#customembed").querySelector(".add-temp"); final isTemp = checkbox.checked; - send({ - type: AddVideo, addVideo: { - item: { - url: iframe, - title: name, - author: personal.name, - duration: 99 * 60 * 60, - isTemp: isTemp, - isIframe: true - }, - atEnd: atEnd - }}); + player.getIframeData(iframe, (data:VideoData) -> { + if (data.duration == 0) { + serverMessage(4, Lang.get("addVideoError")); + return; + } + if (title.length > 0) data.title = title; + if (data.url == null) data.url = iframe; + send({ + type: AddVideo, addVideo: { + item: { + url: data.url, + title: data.title, + author: personal.name, + duration: data.duration, + isTemp: isTemp, + isIframe: true + }, + atEnd: atEnd + }}); + }); } public function toggleVideoElement():Bool { -- cgit v1.2.3