'
);
final deleteBtn = itemEl.querySelector("#btn-delete");
deleteBtn.onclick = (e) -> {
main.send({
type: RemoveVideo,
removeVideo: {
url: itemEl.querySelector(".qe_title").getAttribute("href")
}
});
}
videoItemsEl.appendChild(itemEl);
ge("#plcount").innerHTML = '${items.length} ${Lang.get("videos")}';
ge("#pllength").innerHTML = totalDuration();
}
public function removeVideo():Void {
player.removeChild(video);
video = null;
}
public function removeItem(url:String):Void {
final list = ge("#queue");
for (child in list.children) {
if (child.querySelector(".qe_title").getAttribute("href") == url) {
list.removeChild(child);
break;
}
}
items.remove(
items.find(item -> item.url == url)
);
if (video.src == url) {
if (items.length > 0) setVideo(items[0]);
}
ge("#plcount").innerHTML = '${items.length} ${Lang.get("videos")}';
ge("#pllength").innerHTML = totalDuration();
}
function duration(time:Float):String {
final h = Std.int(time / 60 / 60);
final m = Std.int(time / 60);
final s = Std.int(time % 60);
var time = '$m:';
if (m < 10) time = '0$time';
if (h > 0) time = '$h:$time';
if (s < 10) time = time + "0";
time += s;
return time;
}
function totalDuration():String {
var time = 0.0;
for (item in items) time += item.duration;
return duration(time);
}
function nodeFromString(div:String):Element {
final wrapper = document.createDivElement();
wrapper.innerHTML = div;
return wrapper.firstElementChild;
}
public function isListEmpty():Bool {
return items.length == 0;
}
public function pause():Void {
if (video == null) return;
video.pause();
}
public function play():Void {
if (video == null) return;
video.play();
}
public function setTime(time:Float, isLocal = true):Void {
if (video == null) return;
skipSetTime = isLocal;
video.currentTime = time;
}
public function getTime():Float {
if (video == null) return 0;
return video.currentTime;
}
}