# Init widget script: https://ovp.sohatv.vn/lib/widget-script/ovpWidget.js
# Init player script: https://player.sohatv.vn/resource/init-script/playerInitScript.js
# Init embed player: https://ovp.sohatv.vn/lib/embed/ovpEmbed.js
$(function () {
$("#btn-ovp-video-widget").click(function () {
let { appkey, token } = this.dataset;
let getToken = (cb) => cb(null, token);
ovpWidget.init({
appkey,
token: getToken,
params: {Live: true},
onCallback: (value) => {
console.log('=====onInsertVideo=============', value);
let embedCode = Array.isArray(value.data) ? ovpWidget.embedData() : value.data.embedCode;
if (value.type === 'insertVideo' || value.type === 'insertVideoLive') $("#video-inserted-container").append(embedCode);
}
});
});
})
$(function() {
$("#ovp-upload-input").change(function() {
const {appkey, token} = this.dataset
const {files} = this
const getToken = cb => cb(null, token)
ovpWidget.uploadVideo({
appkey,
token: getToken,
files,
onCallback: (value) => {
console.log('=====onUploadVideo=============', value);
}
});
$("#ovp-upload-input").val('')
})
})