0

Первые наброски объекта-плеера

This commit is contained in:
2017-12-12 14:35:30 +03:00
parent bff5b710b1
commit 1f9cf46b1c
2 changed files with 50 additions and 29 deletions

View File

@@ -0,0 +1,47 @@
const KSPlayer = function(containerId) {
/* --- FIELDS -------------- */
var videoType = 'unknown';
var isShowTitle = false;
/* --- PRIVATE FUNCTIONS --- */
/* --- CONSTRUCTOR --------- */
const containerElement = document.getElementById(containerId);
if (containerElement === null) {
throw `Container "${containerId}" not found!`;
}
let videoElement = document.createElement('video');
videoElement.id = 'player';
videoElement.className = 'center-block';
videoElement.setAttribute('controls', 'controls');
videoElement.setAttribute('preload', 'none');
var titleElement = document.createElement('h2');
titleElement.id = 'title';
containerElement.appendChild(videoElement);
/* --- FUNCTIONS ----------- */
this.getType = function() {
return videoType;
}
this.setTitle = function(text) {
if (text) {
titleElement.innerText = text;
if (!isShowTitle) {
containerElement.insertBefore(titleElement, videoElement);
isShowTitle = true;
}
} else {
if (isShowTitle) {
containerElement.removeChild(titleElement);
isShowTitle = false;
}
}
}
}