1var _playerAndroid = { 2 3 _data: [], 4 _idDataPlaying: null, 5 _idDataPlaylist: null, 6 _tag: null, 7 _saveOffset: null, 8 _deferred: false, 9 _deferredProgram: null, 10 _dvrRequested: null, 11 _trackDuration: null, 12 _srcPlaying: null, 13 _streamType: null, 14 _tagtoggle: "live", 15 _isPlaying: false, 16 _delay: 20, //problema della live troppo indietro rispetto all'orario attuale 17 _isBarOnPressed: false, 18 _format: 'audio', 19 _tagID: "#video-js-object", 20 _changeFormat: null, 21 _counterVideoIos: null, 22 _vanitykeys: {}, 23 _isPreparing: null, 24 _isInFullScreen: false, 25 _firstInit: true, 26 _progress: null, 27 _error: null, 28 _adPlaying: false, 29 _clickTimeout: null, 30 31 init: function () { 32 if ($('main player').length === 0) { 33 var actions = "\n\ 34 <div class='material-icons keyboard_arrow_down' js-action='_player.fullscreen.show()'>keyboard_arrow_up</div>\n\ 35 <div id=\"nextButton\" class='action-button show-if-desktop material-icons' action=\"_player.playlists.next()\">skip_next</div>\n\ 36 <div id=\"forwardButton\" class='action-button show-if-desktop material-icons' action=\"_player.smallForward()\">forward_10</div>\n\ 37 <div class='action-button small play' action='_player.play()'>\n\ 38 <div class='material-icons play-on'>play_circle_outline</div>\n\ 39 <div class='material-icons play-off' action='_player.pause()'>pause_circle_filled</div>\n\ 40 </div>\n\ 41 <div id=\"backwardButton\" class='action-button show-if-desktop material-icons' action=\"_player.smallBackward()\">replay_10</div>\n\ 42 <div id=\"prevButton\" class='action-button show-if-desktop material-icons' action=\"_player.playlists.prev()\">skip_previous</div>\n\ 43 "; 44 // $('main').append("<player id='player-light'><div class=\"bar\"><div class=\"value\" style=\"width: \{offset\}%\"></div></div><thumbnail action='_player.fullscreen.show()'></thumbnail><div class='title' action='_player.fullscreen.show()'></div>\n\ 45 // <description action='_player.fullscreen.show()'></description><video-js data-account=\"18140046001\" data-player=\"GqGkUkBfWn\" data-embed=\"default\" controls='' data-video-id='' data-playlist-id='' data-application-id='' controls playsinline webkit-playsinline autoplay id='video-js-object' class=\"video-js\" preload=\"metadata\" poster='' style=\"display: none\"></video-js><actions>" + actions + "</actions><div class=\"loader\">Loading...</div>\n\ 46 // \n\</player>"); 47 $("#player-light").remove() 48 $('main').append("<player id='player-light'><div class=\"bar\"><div class=\"value\" style=\"width: \{offset\}%\"></div></div><thumbnail action='_player.fullscreen.show()'></thumbnail><div class='title' action='_player.fullscreen.show()'></div>\n\ 49 <description action='_player.fullscreen.show()'></description><actions>" + actions + "</actions><div class=\"loader\">Loading...</div>\n\ 50 \n\</player>"); 51 _adswizz.init( 52 { 53 autoPlay: _init._data !== null ? _init._data['is_player_autoplay'] : false, // When set to false stream will not automatically start 54 audioOnly: true, // Only play audio in the backgroud, default is false 55 // server: _config.app.adServerURL, 56 // endpoint: _config.app.adEndpointURL, 57 // installationId: "trend2000_android", 58 // playerId: "fluidstreampodcasts", 59 // zoneId: "246", 60 // videoZoneId: "247", 61 userAgent: "_android_nerazzura_40003" 62 } 63 ); 64 //player piccolo description = data['abstract'] 65 } 66 }, 67 68 play: async function (idData, idPlaylist, type = "audio", resume = true) { 69 var _this = this; 70 if (idData === undefined || idData === null) { 71 console.info("Play resource not valid!"); 72 return; 73 } 74 var data = _player._data[idData]; 75 76 if (data['status'] == "is-downloading") { 77 _toastmessage.show("536", "warning") 78 return; 79 } 80 81 if (data !== undefined) { 82 if (!_system.isNull(_player._idDataPlaying)) { 83 if (idData != _player._idDataPlaying) { 84 _player._data[_player._idDataPlaying]['is_playing'] = false;
85 // _player._format = 'audio'; 86 } 87 } 88 89 _player._idDataPlaying = idData; 90 _player._idDataPlaylist = (idPlaylist !== undefined ? idPlaylist : (_player._idDataPlaylist !== null ? _player._idDataPlaylist : null)); 91 92 if (_system.isNull(_player._srcPlaying)) { 93 _player._srcPlaying = ""; 94 } 95 96 $('player .title').html(data.title); 97 if (data.type != "live") { 98 $('player description').html(_system.removeTags(data['program'] || data['abstract'] || data['description'])) 99 } else { 100 $('player description').html(_system.label("live")); 101 if (_player.countdownTimer._timer !== null && _player.countdownTimer._endOfEpisode == true) { 102 _toastmessage.show(552); 103 _player.countdownTimer.stop(); 104 } 105 } 106 $('player thumbnail').css("background-image", "url('" + data.image + "')"); 107 108 if ((_player._srcPlaying !== data.source) || (_player._srcPlaying !== data['source-video'] && type == "video") || _player._error == true) { 109 if(_player._tag !== null){ 110 _player.speed.set(1); 111 } 112 _player._error = null; 113 _player._adPlaying = false; 114 115 if (data['source-audio'] === "" && data['source-video'] !== "") { 116 type = "video"; 117 } else if (data['source-audio'] !== "" && data['source-video'] === "") { 118 type = "audio"; 119 } 120 121 $('player .loader').show(); 122 _player._isPreparing = true; 123 if (_init._data !== null && _init._data['is_player_autoplay'] == true && _home.live._autoplay == false) { 124 if (_init._data['is_player_autoplay_fullscreen'] == true) { 125 await _player.fullscreen.show("1"); 126 } else { 127 _player.standard.show(); 128 _player.metadata.init(data.vanityurl); 129 } 130 } else { 131 await _player.fullscreen.show(1); 132 } 133 this.audio.set(); 134 135 if (type == "audio") { 136 137 if (_player._format == "video") { 138 $('.player-commands').detach().insertAfter('#player-full .player-info-main'); 139 _player._tag.dispose(); 140 _adswizz.init( 141 { 142 autoPlay: false, // When set to false stream will not automatically start 143 audioOnly: true, // Only play audio in the backgroud, default is false 144 // server: _config.app.adServerURL, 145 // endpoint: _config.app.adEndpointURL, 146 // installationId: "trend2000_android", 147 // playerId: "fluidstreampodcasts", 148 // zoneId: "246", 149 // videoZoneId: "247" 150 userAgent: "_android_nerazzura_40003" 151 } 152 ); 153 } 154 155 _player._tag = window.ExoPlayer; 156 157 if (data.type == "live") { 158 _player._streamType = "live"; 159 _player.metadata.init(data.vanityurl); 160 if (_player._deferred == true) { 161 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 162 data['source'] = data['source-dvr'].slice(); 163 _player._format = 'audio'; 164 } else { 165 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 166 data['source'] = data['source-audio'].slice(); 167 _player._format = 'audio'; 168 } 169 170 } else { 171 _player._format = 'audio'; 172 _player._streamType = "track"; 173 _player.metadata.remove(); 174 if (data.type != "embedded") 175 data['source'] = ((data['source-audio-local'] === undefined || data['source-audio-local'] === null || data['source-audio-local'] === "") ? data['source-audio'] : data['source-audio-local']).slice(); 176 _player.notification.create(data.title, data.program || data.abstract, data.image); 177 } 178 _player._srcPlaying = data.source; 179 _player._tag.setStream({ 180 url: data.source, 181 type: data.type, 182 }, function (json) { 183 $("player .loader").hide(); 184 _player._tag.getDuration(function (json) { 185 186 if (json['dur'] > 0) 187 _player._trackDuration = json['dur'] 188 189 $('[player-id]').removeClass("is-playing"); 190 $('[player-id="' + _player._idDataPlaying + '"]').addClass("is-playing"); 191 $('player#player-light').addClass("is-playing"); 192 _player._data[_player._idDataPlaying]['is_playing'] = true; 193 194 if (_player._isInFullScreen) { 195 $('#player-full').addClass("is-playing"); 196 _player.fullscreen.update(1, type != _player._format); 197 } 198 199 _player.checkNext(); 200 _player.checkPrev(); 201 $('player#player-light .action-button.play').attr('action', '_player.play("' + idData + '", "' + idPlaylist + '")'); 202 $('player .keyboard_arrow_down').attr('action', '_player.fullscreen.show("1")'); 203 204 if (data.type != "live") { 205 if (Object.keys(_profile.user.log._data).length > 0) { 206 if (!_system.isNull(_profile.user.log._data[_player._idDataPlaying]) && data["type"] !== "embedded") { 207 _player._data[_player._idDataPlaying]['offset'] = _profile.user.log._data[_player._idDataPlaying].offset; 208 } else { 209 _player._data[_player._idDataPlaying]['offset'] = 0; 210 } 211 document.getElementById('progressBar').value = _player._data[_player._idDataPlaying]['offset']; 212 } else { 213 _player._data[_player._idDataPlaying]['offset'] = 0; 214 } 215 }else{ 216 if(document.getElementById('progressBar') !== null) 217 document.getElementById('progressBar').value = 100; 218 }
219 // _player.progressBar.update(); 220 221 _player.audio.play(); 222 _system.logEvent("player", { action: "play", "url": (_player._data[_player._idDataPlaying].source !== undefined ? _player._data[_player._idDataPlaying].source : "") }); 223 224 225 clearInterval(_player._progressInterval); 226 227 _player._progressInterval = setInterval(function () { 228 _player._tag.getCurrentPosition(function (json) { 229 _player._isPreparing = false; 230 if ((json["status"] == "FAILED" || json['status'] == "PAUSED") && _player._isPlaying) { 231 if (json["status"] == "FAILED") { 232 _player._error = true; 233 if (_player._streamType == "live") { 234 _toastmessage.show(531, "warning"); 235 } else { 236 _toastmessage.show(523, "warning"); 237 } 238 _player.pause(); 239 } 240 } 241 _player._adPlaying = json["adPlaying"]; 242 _player._progress = json['pos']; 243 if (json['dur'] > 0) 244 _player._trackDuration = json['dur']; 245 if (_player._trackDuration > 0 && _player._progress >= (_player._trackDuration - 1) && _player._isPlaying) { 246 _player._progress = _player._trackDuration; 247 if(_player.countdownTimer._timer !== null && _player.countdownTimer._endOfEpisode == true){ 248 _player.countdownTimer.stop(); 249 _player.pause(); 250 }else{ 251 _player.playlists.next(); 252 } 253 } 254 _player.progressBar.update(); 255 }, function (error) { 256 console.log(error) 257 _player._progress = 0; 258 }); 259 }, 500); 260 261 clearInterval(_player._saveOffset); 262 if (data.type !== "embedded" && data.type !== "live") { 263 _player._saveOffset = setInterval(function () { 264 if (_player._data[_player._idDataPlaying]['offset'] > 0 && !_advertising.preroll.isPlayingAd) { 265 _profile.user.log._data[_player._idDataPlaying] = { offset: _player._data[_player._idDataPlaying]['offset'], timestamp: new Date().getTime(), episode_id: _player._data[_player._idDataPlaying]["episode_id"] }; 266 _profile.user.log.setValue("audio", _player._idDataPlaying, _profile.user.log._data[_player._idDataPlaying]); 267 } 268 }, 10000); 269 } 270 }, function (error) { 271 console.log(error) 272 }); 273 }, function (error) { 274 console.log(error) 275 }); 276 277 } else { 278 if (_player._format == "audio") { 279 clearInterval(_player._progressInterval); 280 if($('.video-player video-js').length === 0){ 281 $('.video-player').append("<video-js controls playsinline data-video-id='' data-playlist-id='' data-application-id='' controls id='video-js-object' class=\"video-js\" preload=\"metadata\" poster='' style=\"display: none\"></video-js>"); 282 } 283 if (_player._tag) _player._tag.close(); 284 // await $.getScript("https://players.brightcove.net/18140046001/GqGkUkBfWn_default/index.min.js", function (data, textStatus, jqxhr) { 285 286 // }) 287 // await $.getScript("https://cdn.jsdelivr.net/npm/videojs-landscape-fullscreen/dist/videojs-landscape-fullscreen.js", function (data, textStatus, jqxhr) { 288 289 // }) 290 } 291 if(_player.countdownTimer._timer !== null){ 292 _toastmessage.show(553); 293 _player.countdownTimer.stop(); 294 } 295 // $.getScript("https://players.brightcove.net/18140046001/GqGkUkBfWn_default/index.min.js", function (data, textStatus, jqxhr) { 296 _player._tag = videojs(_player._tagID).ready(function () { 297 // this.tech_.el_.setAttribute('playsinline', 'playsinline'); 298 // this.tech_.supportsFullScreen = function () { 299 // return false;
300 // }; 301 // this.landscapeFullscreen({ 302 // enterOnRotate: true, // Enter fullscreen mode on rotating the device in landscape 303 // exitOnRotate: true, // Exit fullscreen mode on rotating the device in portrait 304 // alwaysInLandscapeMode: true, // Always enter fullscreen in landscape mode even when device is in portrait mode (works on chromium, firefox, and ie >= 11) 305 // }); 306 307 _player._tag = this; 308 _player._isPreparing = false; 309 var data = _player._data[_player._idDataPlaying] 310 _player._tag.poster(data.image); 311 _player._tag.muted(false) 312 313 this.off('click'); 314 this.on('click', function(event) { 315 if (_player._tag.userActive() === true) { 316 if ($('.player-commands').height() < (screen.height - event.y)) { 317 _player._tag.userActive(false); 318 }else{ 319 _player._tag.userActive(true); 320 clearTimeout(_player._clickTimeout); 321 _player._clickTimeout = setTimeout(function () { 322 _player._tag.userActive(false); 323 }, 5000); 324 } 325 } else { 326 _player._tag.userActive(true); 327 clearTimeout(_player._clickTimeout); 328 _player._clickTimeout = setTimeout(function () { 329 _player._tag.userActive(false); 330 }, 5000); 331 } 332 }); 333 334 if (data.type == "live") { // se live e uso loadmetadata (che mi serve per avere audio) non va avanti 335 _player._streamType = "live"; 336 337 if (type == "video") { 338 data['source'] = data['source-video'].slice(); 339 340 // if (window.screen.orientation !== undefined) window.screen.orientation.unlock(); 341 // if (_player._tag.controlBar.getChild('FullscreenToggle') !== null) { 342 // this.getChild('controlBar').removeChild('FullscreenToggle'); 343 // } 344 345 this.width($('#modal .body .video-player').innerWidth() || (screen.width > 1200 ? 640 : screen.width)); 346 this.height(($('#modal .body .video-player').innerWidth() || (screen.width > 1200 ? 640 : screen.width)) * 9 / 16); 347 _player._format = 'video'; 348 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 349 } 350 351 _player._srcPlaying = data.source; 352 353 _player._tag.src(data.source); 354 355 // $("player .loader").hide(); 356 357 this.on('timeupdate', function () { 358 // $("player .loader").hide(); 359 var duration = ((new Date().getHours() * 60 * 60 + new Date().getMinutes() * 60 + new Date().getSeconds()) - _player._data[_player._idDataPlaying]['time_from'] / 1000) - _player._delay; 360 361 if (duration > _player._data[_player._idDataPlaying]['duration']) { 362 _player._trackDuration = _player._data[_player._idDataPlaying]['duration']; 363 if (_player._deferred == true) { 364 _player._deferredProgram = true; 365 currentTime = _player._progress; 366 } else { 367 currentTime = duration; 368 } 369 } else { 370 _player._trackDuration = duration; 371 currentTime = _player._progress; 372 } 373 if ((_player._trackDuration - currentTime) < 0) { //quando finisce la traccia 374 _home.live.check();
375 if (_app.isAppInBackground == false) { 376 _player.playlists.next(); 377 } 378 } 379 _player.progressBar.update(); 380 }) 381 382 383 this.on('play', () => { 384 $("player .loader").hide(); 385 _player._tag.muted(false) 386 387 //_player.notification._musicControls.updateIsPlaying(true); 388 }); 389 390 this.on('error', function () { 391 if (_player._deferred) { 392 _toastmessage.show(522, "warning"); 393 setTimeout(function () { 394 _player.startLiveToggle("live"); 395 }, 3000); 396 } else { 397 _toastmessage.show(531, "warning"); 398 } 399 }); 400 401 _player._tag.errors(); 402 _player._tag.errors.getAll(); 403 404 // _player.metadata.get(); 405 // _player.metadata.update(); 406 _player.metadata.init(data.vanityurl); 407 $('[player-id]').removeClass("is-playing"); 408 $('[player-id="' + _player._idDataPlaying + '"]').addClass("is-playing"); 409 $('player#player-light').addClass("is-playing"); 410 _player._data[_player._idDataPlaying]['is_playing'] = true; 411 412 if (_player._isInFullScreen) { 413 $('#player-full').addClass("is-playing"); 414 _player.fullscreen.update(1, type != _player._format); 415 } 416 417 _player.checkNext(); 418 _player.checkPrev(); 419 $('player#player-light .action-button.play').attr('action', '_player.play("' + idData + '", "' + idPlaylist + '")'); 420 // $('player .keyboard_arrow_down').parent().attr('href', _system.createLink(window.location.href + 'episodi/' + _player._idDataPlaying)); 421 //$('player .keyboard_arrow_down').parent().attr('href', _system.createLink(window.location.href.split("#")[1] + '/episodi/' + _player._idDataPlaying)); 422 // $('player .keyboard_arrow_down').parent().attr('href', _system.createLink('live')); 423 $('player .keyboard_arrow_down').attr('action', '_player.fullscreen.show("1")'); 424 425 // if (Object.keys(_profile.user.log._data).length > 0) { 426 // if (!_system.isNull(_profile.user.log._data[_player._idDataPlaying]) && data["type"] !== "embedded") { 427 // _player._data[_player._idDataPlaying]['offset'] = _profile.user.log._data[_player._idDataPlaying].offset; 428 // } else { 429 // _player._data[_player._idDataPlaying]['offset'] = 0; 430 // } 431 // } 432 433 _player.audio.play(); 434 _system.logEvent("player", { action: "play", "url": (_player._data[_player._idDataPlaying].source !== undefined ? _player._data[_player._idDataPlaying].source : "") }); 435 436 // clearInterval(_player._saveOffset); 437 438 // if (_profile.isLogged()) { 439 // _player._saveOffset = setInterval(function () { 440 // if (_player._data[_player._idDataPlaying]['offset'] > 0) { 441 // _profile.user.log._data[_player._idDataPlaying] = { offset: _player._data[_player._idDataPlaying]['offset'], timestamp: new Date().getTime(), episode_id: _player._data[_player._idDataPlaying]["episode_id"] }; 442 // _profile.user.log.setValue("audio", _player._idDataPlaying, _profile.user.log._data[_player._idDataPlaying]); 443 // } 444 // }, 10000); 445 // } 446 447 this.off('loadedmetadata'); 448 449 } else { 450 451 if (type == "video") { 452 data['source'] = data['source-video'].slice(); 453 454 // if (window.screen.orientation !== undefined) window.screen.orientation.unlock(); 455 // if (_player._tag.controlBar.getChild('FullscreenToggle') !== null) { 456 // this.getChild('controlBar').removeChild('FullscreenToggle'); 457 // } 458 459 this.width($('#modal .body .video-player').innerWidth() || (screen.width > 1200 ? 640 : screen.width)); 460 this.height(($('#modal .body .video-player').innerWidth() || (screen.width > 1200 ? 640 : screen.width)) * 9 / 16); 461 _player._format = 'video'; 462 $('.vjs-loading-spinner').show(); 463 $('.vjs-progress-control').css("opacity", "0"); 464 $('.vjs-progress-control').css("pointer-events", "none"); 465 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 466 } else { 467 this.width(0); 468 this.height(0); 469 data['source'] = (data['source-audio-local'] === undefined || data['source-audio-local'] === null || data['source-audio-local'] == "" ? data['source-audio'] : data['source-audio-local']).slice(); 470 _player._format = 'audio'; 471 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 472 } 473 this.on('error', function () { 474 _toastmessage.show(523, "warning"); 475 }); 476 _player._tag.errors(); 477 _player._tag.errors.getAll(); 478 479 if (data.source.indexOf("ref:") == 0 || data.source.indexOf("id:") == 0) { 480 if (data.source.indexOf("id:") == 0) { 481 data.source = data.source.replace("id:", "") 482 } 483 _player._tag.catalog.getVideo(data.source, function (error, video) { 484 _player._tag.catalog.load(video); 485 $("player .loader").hide(); 486 }) 487 } else { 488 // if (data.type != "embedded") { 489 // // data['source'] = (_adswizz.decorateURL(data['source-audio']) + (data['source-audio'].indexOf("?") > 0 ? "&" : "?") + "aw_0_req.userConsentV2=" + _cookies.get("eupubconsent-v2")).slice() 490 // // data['source'] = (_adswizz.decorateURL(data['source-audio'])).slice() 491 // if (type == "video") { 492 // data['source'] = data['source-video'] 493 // }else{ 494 // data['source'] = (_adswizz.decorateURL(data['source-audio'])).slice() 495 // } 496 // } 497 _player._tag.src(data.source)//(type == "audio" ? { src: data.source, type: "audio/mp3" } : { src: data.source, type: "video/mp4" }); 498 } 499 500 _player._srcPlaying = data.source; 501 this.on('loadedmetadata', function () { 502 _player._streamType = "track"; 503 _player._deferred = false;
504 _player._trackDuration = _player._tag.duration(); 505 506 _player.notification.create(data.title, data.program || data.abstract, data.image); 507 508 this.on('timeupdate', function () { 509 _player._progress = _player._tag.currentTime(); 510 _player._trackDuration = _player._tag.duration(); 511 _player.progressBar.update(); 512 }) 513 514 this.on('ended', function () { 515 console.log("TRACCIA FINITA") 516 // _player._data[_player._idDataPlaying]['offset'] = 0; 517 if (_player.playlists.nextId() === undefined && _player._streamType != "live") { 518 _player.pause(); 519 } else { 520 if (_player.countdownTimer._timer !== null && _player.countdownTimer._endOfEpisode == true) { 521 _player.countdownTimer.stop(); 522 } else { 523 _player.playlists.next(); 524 } 525 } 526 }) 527 528 this.on('play', () => { 529 $("player .loader").hide(); 530 _player._tag.muted(false) 531 // _player.notification._musicControls.updateIsPlaying(true); 532 }); 533 534 _player.metadata.remove(); 535 $('[player-id]').removeClass("is-playing"); 536 $('[player-id="' + _player._idDataPlaying + '"]').addClass("is-playing"); 537 $('player#player-light').addClass("is-playing"); 538 _player._data[_player._idDataPlaying]['is_playing'] = true; 539 540 if (_player._isInFullScreen) { 541 $('#player-full').addClass("is-playing"); 542 _player.fullscreen.update(1, type != _player._format); 543 } 544 // else if (true) { // flag per far partire play 545 546 // } else { 547 // _player.metadata.update(); 548 // _player.standard.show(); 549 // $('.video-js').hide(); 550 // } 551 552 _player.checkNext(); 553 _player.checkPrev(); 554 $('player#player-light .action-button.play').attr('action', '_player.play("' + idData + '", "' + idPlaylist + '")'); 555 $('player .keyboard_arrow_down').attr('action', '_player.fullscreen.show("1")'); 556 557 if (Object.keys(_profile.user.log._data).length > 0) { 558 if (!_system.isNull(_profile.user.log._data[_player._idDataPlaying]) && data["type"] !== "embedded") { 559 _player._data[_player. 560 _idDataPlaying]['offset'] = _profile.user.log._data[_player._idDataPlaying].offset; 561 } else { 562 _player._data[_player._idDataPlaying]['offset'] = 0; 563 } 564 } 565 566 _player.audio.play(); 567 _system.logEvent("player", { action: "play", "url": (_player._data[_player._idDataPlaying].source !== undefined ? _player._data[_player._idDataPlaying].source : "") }); 568 569 clearInterval(_player._saveOffset); 570 if (data.type !== "embedded" && data.type !== "live") {
571 _player._saveOffset = setInterval(function () { 572 if (_player._data[_player._idDataPlaying]['offset'] > 0 && !_advertising.preroll.isPlayingAd) { 573 _profile.user.log._data[_player._idDataPlaying] = { offset: _player._data[_player._idDataPlaying]['offset'], timestamp: new Date().getTime(), episode_id: _player._data[_player._idDataPlaying]["episode_id"] }; 574 _profile.user.log.setValue("audio", _player._idDataPlaying, _profile.user.log._data[_player._idDataPlaying]); 575 } 576 }, 10000); 577 } 578 this.off('loadedmetadata'); 579 }) 580 } 581 }) 582 } 583 } else { //se è giàinstaziato non lo rifaccio 584 585 $('[player-id]').removeClass("is-playing"); 586 $('[player-id="' + _player._idDataPlaying + '"]').addClass("is-playing"); 587 $('player#player-light').addClass("is-playing"); 588 _player._data[_player._idDataPlaying]['is_playing'] = true; 589 590 if (_player._isInFullScreen) { 591 $('#player-full').addClass("is-playing"); 592 _player.fullscreen.update(1); 593 } else { 594 _player.standard.show(); 595 _player.metadata.init(data.vanityurl); 596 } 597 598 if (data.type != 'live') { 599 _player.checkNext(); 600 _player.checkPrev(); 601 // _player.notification.create(data.title, data.program || data.abstract, data.image); 602 } else { 603 // if (((_init._data["is_metadata"] && _player.metadata._vanityRendering == "main") || _player.metadata._vanityRendering != "main") && _player.metadata._vanityRendering !== null) { 604 // _player.notification.create(data.title, _player.metadata._title + " - " + _player.metadata._author, _init._data.cover || _config.app.radio.logo); 605 // }else{ 606 // _player.notification.create(_config.app.radio.name, _system.label("live"), _init._data.cover || _config.app.radio.logo); 607 // } 608 } 609 610 $('player#player-light .action-button.play').attr('action', '_player.play("' + idData + '", "' + idPlaylist + '")'); 611 //$('player .keyboard_arrow_down').parent().attr('href', _system.createLink(window.location.href.split("#")[1] + '/episodi/' + _player._idDataPlaying)); 612 // var playingId = (!_system.isNull(_player._data[_player._idDataPlaying].vanityurl) ? _player._data[_player._idDataPlaying].vanityurl : (!_system.isNull(_player._idDataPlaying) ? _player._idDataPlaying : null)); 613 614 $('player .keyboard_arrow_down').attr('action', '_player.fullscreen.show("1")'); 615 616 if (!_system.isNull(_profile.user.log._data[_player._idDataPlaying])) { 617 _player._data[_player._idDataPlaying]['offset'] = _profile.user.log._data[_player._idDataPlaying].offset; 618 } 619 if (_player.notification._musicControls) { 620 _player.notification._musicControls.updateIsPlaying(true); 621 } 622 623 _player.audio.play(resume); 624 if(resume){ 625 _system.logEvent("player", { action: "play", "url": (data['source'] !== undefined ? data['source'] : ""), "resume": resume }); 626 } 627 clearInterval(_player._saveOffset); 628 if (data.type !== "embedded" && data.type !== "live") { 629 _player._saveOffset = setInterval(function () { 630 _profile.user.log._data[_player._idDataPlaying] = { offset: _player._data[_player._idDataPlaying]['offset'], timestamp: new Date().getTime(), episode_id: _player._data[_player._idDataPlaying]["episode_id"] }; 631 _profile.user.log.setValue("audio", _player._idDataPlaying, _profile.user.log._data[_player._idDataPlaying]); 632 }, 10000); 633 } 634 } 635 } else { 636 _player.standard.hide(); 637 } 638 }, 639 640 // showEpisode: async function (idEpisode, idProgramma, type = "audio") { //not used 641 642 // if (idEpisode === undefined || idEpisode === null) { 643 // _toastmessage.show("535", "error"); 644 // return; 645 // } 646 // var data; 647 // if (_player._data[idEpisode] !== undefined) { 648 // //Accesso tramite ID 649 // data = _player._data[idEpisode]; 650 // } else if (_this._vanitykeys !== undefined && _player._data[_this._vanitykeys[idEpisode]] !== undefined) { 651 // //Accesso tramite vanity 652 // data = _player._data[_this._vanitykeys[idEpisode]]; 653 // idEpisode = _this._vanitykeys[idEpisode]; 654 // } else { 655 // //Verifica tramite chiave vanityurl 656 // for (var key in _player._data) { 657 // if (_player._data[key]['vanityurl'] === idEpisode) { 658 // idEpisode = key; 659 // data = _player._data[id]; 660 // } 661 // } 662 // } 663 664 // //imposto tag meta 665 // var metaTitle; 666 // var metaDesc; 667 // var metaImage; 668 // var indexingRule = ""; 669 // if (data['meta'] === undefined || data['meta'] == null) { 670 // metaTitle = data['title']; 671 // metaDesc = data['description']; 672 // metaImage = data['image']; 673 // } 674 // else { 675 // metaTitle = data['meta']['title'] !== "" ? data['meta']['title'] : data['title']; 676 // metaDesc = data['meta']['description'] !== "" ? data['meta']['description'] : data['description']; 677 // metaImage = data['meta']['image'] !== "" ? data['meta']['image'] : data['image']; 678 // indexingRule = data['meta']['indexing_rule']; 679 // } 680 // _head.renderAll(metaTitle, metaDesc, metaImage, metaType, indexingRule); 681 682 // if (data['vanityurlProgram'] == idProgramma) { 683 // idProgramma = data['program_id']; 684 // } 685 686 // if (data !== undefined) { 687 // if (!_system.isNull(_player._idDataPlaying)) { 688 // if (idEpisode != _player._idDataPlaying) { 689 // _player._data[_player._idDataPlaying]['is_playing'] = false;
690 // _player._format = 'audio'; 691 // } 692 // } 693 // _player._idDataPlaying = idEpisode; 694 695 // if (_player._idDataPlaylist === undefined || _player._idDataPlaylist === null) { 696 // if (data.episode_type == "episodes" || data.episode_type == "pills") { 697 // _player._idDataPlaylist = data.program_id; 698 // if (!(data.program_id in _player.playlists._data)) { 699 // _player.playlists.create(data.program_id); 700 // } 701 // } else { 702 // _player._idDataPlaylist = data.type; 703 // } 704 // } 705 // // _player._idDataPlaylist = data.type; 706 // // _player._idDataPlaylist = (idProgramma !== undefined ? idProgramma : (_player._idDataPlaylist !== null ? _player._idDataPlaylist : null)); 707 // $('player .title').html(data.title); 708 // $('player description').html(data.program); 709 // $('player thumbnail').css("background-image", "url('" + data.image + "')"); 710 // $('player#player-light .action-button.play').attr('action', '_player.play("' + idEpisode + '", "' + idProgramma + '")'); 711 712 // /* _player._tag = videojs(_player._tagID, { 713 // autoplay: 'any', 714 // "controlBar": { "pictureInPictureToggle": false } 715 // }, function onPlayerReady() { 716 // _player._tag.src(data.source); 717 // });*/ 718 // } 719 // else { 720 // _system.goToPage("404") 721 // return 404; 722 // } 723 // }, 724 725 pause: function () { 726 $('body').removeClass("is-player-playing"); 727 _player._isPlaying = false; 728 _player._isPaused = true; 729 $('player#player-light').removeClass("is-playing"); 730 $('#player-full').removeClass("is-playing"); 731 $('[player-id]').removeClass("is-playing"); 732 _player.audio.pause(); 733 if (_player.notification._musicControls) _player.notification._musicControls.updateIsPlaying(false); 734 // _player._data[_player._idDataPlaying]['offset'] = _player.audio.getOffset(); 735 _player._data[_player._idDataPlaying]['is_playing'] = false; 736 // _player._format = ""; 737 // $('player .keyboard_arrow_down').parent().attr('href', _system.createLink(data.type)); 738 $('player .keyboard_arrow_down').attr('js-action', '_player.fullscreen.show("0")'); 739 _player.progressBar.update(); 740 // clearInterval(_player._saveOffset); 741 // clearInterval(_player._progressInterval); 742 if (_profile.isLogged() && _player._streamType != "live") { 743 _profile.user.log.setValue("audio", _player._idDataPlaying, { offset: _player._data[_player._idDataPlaying]['offset'], timestamp: new Date().getTime(), episode_id: _player._data[_player._idDataPlaying]["episode_id"] }); 744 } 745 _system.logEvent("player", { action: "pause", "url": (_player._data[_player._idDataPlaying].source !== undefined ? _player._data[_player._idDataPlaying].source : "") }); 746 return false; 747 }, 748 749 smallForward: function () { 750 _player.audio.smallForward(); 751 if (_player._deferred == true) { 752 if ((_player._trackDuration - _player._progress) < 0) { 753 _player.audio.returnLive(); 754 _player.showStart(); 755 } 756 } 757 }, 758 759 smallBackward: function () { 760 _player.audio.smallBackward(); 761 if (_player._deferred == false && _player._streamType == "live") { 762 _player.showLive(); 763 _player._deferred = true; 764 } 765 }, 766 767 startLiveToggle: function (option) { 768 if (_player._streamType != "live") { 769 $('.home-live-play-button').trigger("tap"); 770 } 771 if (_player._format == "audio") { 772 if (_init._data.is_dvr_audio) { 773 if (option == 'start') { 774 _player.audio.returnStart(); 775 _player.showLive(); 776 _player._deferred = true; 777 _player.progressBar.updateDescriptionPlayer(); 778 } else if (option == 'live') { 779 _player.audio.returnLive(); 780 _player.showStart(); 781 _player._deferred = false;
782 } 783 } else { 784 //_toastmessage.show('533', "warning"); 785 return; 786 } 787 } else if (_player._format == "video") { 788 if (_init._data.is_dvr_video) { 789 if (option == 'start') { 790 _player.audio.returnStart(); 791 _player.showLive(); 792 _player._deferred = true; 793 _player.progressBar.updateDescriptionPlayer(); 794 } else if (option == 'live') { 795 _player.audio.returnLive(); 796 _player.showStart(); 797 _player._deferred = false; 798 } 799 } else { 800 //_toastmessage.show('534', "warning"); 801 return; 802 } 803 } 804 805 return false; 806 }, 807 808 hideStartLive: function () { 809 $('#player-full button.return-start').hide(); 810 $('#player-full button.return-live').hide(); 811 }, 812 813 showLive: function () { 814 $('button.return-start').hide(); 815 $('button.return-live').html(_system.label('return-live')); 816 $('button.return-live').show(); 817 _player._tagtoggle = "start"; 818 }, 819 820 showStart: function () { 821 $('button.return-live').hide() 822 $('button.return-start').html(_system.label('return-start')) 823 $('button.return-start').show() 824 _player._tagtoggle = "live"; 825 }, 826 827 checkPrev: function () { 828 if (_player.playlists.prevId() === undefined || _player._streamType == 'live') { 829 $('[id=prevButton], actions [id=prevButton]').addClass("disabled"); 830 } else { 831 $('[id=prevButton], actions [id=prevButton]').removeClass("disabled"); 832 } 833 }, 834 835 checkNext: function () { 836 if (_player.playlists.nextId() === undefined || _player._streamType == 'live') { 837 $('[id=nextButton], actions [id=nextButton]').addClass("disabled"); 838 } else { 839 $('[id=nextButton], actions [id=nextButton]').removeClass("disabled"); 840 } 841 }, 842 843 refreshFromBackground: function () { 844 // if (_player._streamType == "live") { 845 // if (_player._deferred == true) { 846 // _player.play(_player._idDataPlaying); 847 // } else { 848 // _home.live.check(); 849 // _player.play(_home._idProgramLive, "live"); 850 // } 851 // } else { 852 // _player.play(_player._idDataPlaying); 853 // } 854 }, 855 856 videoAudioToggle: function () { 857 var _this = this; 858 if (_this._format === 'video') { 859 _this._format = 'audio'; 860 861 $("#player-thumbnail").show(); 862 $(".video-player-container").hide(); 863 $('video').hide(); 864 $('.video-js').hide(); 865 } else if (_this._format === 'audio') { 866 _this._format = 'video'; 867 $(".video-player-container").show(); 868 $('.video-js').show(); 869 $('video').show(); 870 $("#video-js-object").detach().appendTo(".video-player"); 871 $("#player-thumbnail").hide(); 872 // if (window.screen.orientation !== undefined) window.screen.orientation.unlock(); 873 } else { 874 875 } 876 }, 877 878 findMediaTags: function (html, title, image, categoryId) { 879 if (_system.isNull(html)) { 880 return "" 881 } 882 var parser = new DOMParser(); 883 var doc = parser.parseFromString(html, 'text/html'); 884 _player.playlists.create(categoryId); 885 var audios = doc.getElementsByTagName('audio'); 886 var medias = doc.querySelectorAll('video, audio'); 887 let _html = html; 888 let _title = title; 889 let _image = image; 890 let _categoryId = categoryId 891 if (medias.length > 0) { 892 Array.from(medias).map(element => { 893 if (element.tagName == "AUDIO") { 894 var src = element.src; 895 var idPlayer = CryptoJS.MD5(src).toString(); 896 var action = "_player.play('" + idPlayer + "', '" + categoryId + "', 'audio')"; 897 var mediaTitle = element.getAttribute('title'); 898 var offset = 0; 899 if (!_system.isNull(_profile.user.log._data[idPlayer])) { 900 offset = _profile.user.log._data[idPlayer].offset; 901 } 902 _player.playlists.add(categoryId, idPlayer); 903 if (!_player._data[idPlayer]) { 904 _player._data[idPlayer] = { 905 title: mediaTitle, 906 description: "", 907 abstract: _title || "", 908 image: _image, 909 source: src || "", 910 "source-audio": src || "", 911 "speakers": "", 912 type: "audio", 913 } 914 } 915 element.outerHTML = '<article class="episodes p-t-10 m-t-10 m-b-10 t-border-top t-border-bottom" player-id="' + idPlayer + '">\n\ 916 <div class="actions">\n\ 917 <div class="action-button play">\n\
918 <span title="Play" class="material-icons play-on" action="'+ action + '">play_circle_outline</span>\n\ 919 <span title="Pausa" class="material-icons play-off" action="_player.pause()">pause_circle_filled</span>\n\ 920 </div>\n\ 921 </div>\n\ 922 <div class="content p-b-10 no-margin flex-align-center">\n\ 923 <h3 class="t-clamp-2">'+ mediaTitle + '</h3>\n\ 924 </div>\n\ 925 <div class="bar">\n\ 926 <div class="value" style="width: '+ offset + '%"></div>\n\ 927 </div>\n\ 928 </article>'; 929 } else { 930 var src = element.getAttribute('data-ref'); 931 var idPlayer = CryptoJS.MD5(src).toString(); 932 var action = "_player.play('" + idPlayer + "', '" + categoryId + "', 'video')"; 933 var mediaTitle = element.getAttribute('title'); 934 var mediaDescription = element.getAttribute('data-description') || ""; 935 var image = element.getAttribute('poster'); 936 var offset = 0; 937 if (!_system.isNull(_profile.user.log._data[idPlayer])) { 938 offset = _profile.user.log._data[idPlayer].offset; 939 } 940 941 _player.playlists.add(categoryId, idPlayer); 942 if (!_player._data[idPlayer]) { 943 _player._data[idPlayer] = { 944 title: mediaTitle, 945 description: mediaDescription, 946 abstract: _title || "", 947 image: image, 948 source: src, 949 "source-audio": "", 950 "source-video": src, 951 "speakers": "", 952 type: "video", 953 } 954 } 955 element.outerHTML = '<article class="inline-videos p-t-20 m-t-10 m-b-10 t-border-top t-border-bottom" player-id="' + idPlayer + '">\n\ 956 <thumbnail>\n\ 957 <div class="lazy" style="background-image: url(' + image + ')">\n\ 958 <div class="action-button play">\n\ 959 <span title="Play" class="material-icons play-on" action="' + action + '">ondemand_video</span>\n\ 960 <span title="Pausa" class="material-icons play-off" action="_player.pause()">pause_circle_filled</span>\n\ 961 </div>\n\ 962 </div>\n\ 963 </thumbnail>\n\ 964 <div class="content p-b-10 no-margin">\n\ 965 <h3 class="t-clamp-2">'+ mediaTitle + '</h3>\n\ 966 <div class="t-mini t-gray t-clamp-2">' + mediaDescription + '</div>\n\ 967 </div>\n\ 968 <div class="bar" style="position: absolute; bottom: 0;">\n\ 969 <div class="value" style="width: '+ offset + '%"></div>\n\ 970 </div>\n\ 971 </article>'; 972 } 973 }); 974 } 975 return doc.body.innerHTML; 976 }, 977 978 audio: { 979 980 smallPause: false, 981 982 set: function (source) { 983 // $('player video').attr('id', "player"); 984 if (_player._changeFormat !== true) this.smallPause = false; 985 }, 986 987 play: function (resume = true) { 988 //Effettua il play dell'audio 989 if (this.smallPause == false) { 990 if (_player._streamType == "live") { 991 if (_player._dvrRequested !== null) { 992 if (_player._dvrRequested == -10) { 993 // _player._tag.currentTime(_player._trackDuration - 10); 994 } else { 995 var valueRestart = _player._dvrRequested * _player._trackDuration / 100; 996 if (valueRestart <= 0) valueRestart = 0.1; 997 // _player._tag.currentTime(valueRestart); 998 } 999 _player._dvrRequested = null; 1000 } else if (_player._deferredProgram == true) { 1001 _player.startLiveToggle("start"); 1002 _player._deferredProgram = false;
1003 } else { 1004 _player._tag.play(); 1005 } 1006 } else if (_player._data[_player._idDataPlaying]['offset'] > 0 && _player._data[_player._idDataPlaying]['offset'] !== undefined && _player._data[_player._idDataPlaying]['offset'] !== NaN) { 1007 if (_player._data[_player._idDataPlaying]['offset'] > 98) { 1008 _player.progressBar.set(0.1); 1009 } else { 1010 _player.progressBar.set(_player._data[_player._idDataPlaying]['offset']); 1011 } 1012 } 1013 if (_player._changeFormat == true && _player._streamType == "live") { 1014 // _player.audio.returnLive(); 1015 } else { 1016 _advertising.preroll.init(); 1017 // _player._tag.play(); 1018 } 1019 1020 if(_home.live._forceAutoplay == true){ 1021 _home.live._forceAutoplay = false 1022 } 1023 } else { 1024 if (_player._streamType == "live" && _player._deferred == false) { 1025 if (!_player._changeFormat){ 1026 _player._tag.play(); 1027 } 1028 } else if (_player._changeFormat == true) { 1029 if (_player._streamType != "live") { 1030 _player._tag.currentTime(_player._data[_player._idDataPlaying]['offset'] * _player._trackDuration / 100); 1031 } 1032 setTimeout(function () { 1033 _player.pause(); 1034 }, 500); 1035 } else { 1036 _player._tag.play(); 1037 if (_player._data[_player._idDataPlaying]['offset'] > 99.9) { 1038 _player.progressBar.set(0.1); 1039 } 1040 } 1041 1042 if(_home.live._forceAutoplay == true){ 1043 _home.live._forceAutoplay = false 1044 } 1045 } 1046 if (_player._changeFormat == true) { 1047 _player._changeFormat = false; 1048 } 1049 1050 $('body').addClass("is-player-playing"); 1051 _player._isPlaying = true; 1052 _player._isPaused = null; 1053 this.smallPause = false; 1054 }, 1055 1056 pause: function () { 1057 _player._tag.pause(); 1058 this.smallPause = true; 1059 }, 1060 1061 getOffset: function () { 1062 return _player._progress * 100 / _player._trackDuration; 1063 }, 1064 1065 smallForward: function () { 1066 if (_player._tag === window.ExoPlayer) { 1067 _player._tag.currentTime((100 * (_player._progress + 10)) / _player._trackDuration); 1068 } else { 1069 _player._tag.currentTime(_player._progress + 10); 1070 } 1071 if (_player.countdownTimer._timer !== null && _player.countdownTimer._endOfEpisode == true) { 1072 _player.countdownTimer.start(_player._trackDuration - _player._progress + 10); 1073 } 1074 }, 1075 1076 smallBackward: function () { 1077 if (_player._deferred == true || _player._streamType != 'live') { 1078 if (_player._tag === window.ExoPlayer) { 1079 _player._tag.currentTime((100 * (_player._progress - 10)) / _player._trackDuration); 1080 } else { 1081 _player._tag.currentTime(_player._progress - 10); 1082 } 1083 if (_player.countdownTimer._timer !== null && _player.countdownTimer._endOfEpisode == true) { 1084 _player.countdownTimer.start(_player._trackDuration - _player._progress - 10); 1085 } 1086 } else { 1087 _player._deferred = true; 1088 _player._dvrRequested = -10; 1089 _player._srcPlaying = ""; 1090 _player.play(_player._idDataPlaying, _player._idDataPlaylist, _player._format); 1091 } 1092 }, 1093 1094 returnStart: function () { 1095 if (_player._deferred == true || _player._streamType != 'live') { 1096 _player._tag.currentTime(0); 1097 if (_player.countdownTimer._timer !== null && _player.countdownTimer._endOfEpisode == true) { 1098 _player.countdownTimer.start(_player._trackDuration - 5); 1099 } 1100 } else { 1101 _player._deferred = true; 1102 _player._dvrRequested = 0; 1103 _player._srcPlaying = ""; 1104 _player.play(_player._idDataPlaying, _player._idDataPlaylist, _player._format); 1105 } 1106 }, 1107 1108 returnLive: function () { 1109 _player._srcPlaying = ""; 1110 _player._dvrRequested = null; 1111 _player._deferred = false;
1112 // if (!$('body').hasClass('show-modal')) _player._format = 'audio'; 1113 if (_player._deferredProgram) _player._idDataPlaying = _player.playlists.nextId() 1114 _player.play(_player._idDataPlaying, _player._idDataPlaylist, _player._format); 1115 } 1116 1117 }, 1118 1119 speed: { 1120 _speedSelected: 1, 1121 1122 showMenu: function () { 1123 var _this = this 1124 // show modal with 0.8x, 1x, 1.2x, 1.5x, 2.0x options and call player playbackRate function 1125 var speeds = [0.5, 0.8, 1, 1.2, 1.5, 2.0]; 1126 var speedString = []; 1127 1128 speeds.forEach(function (speed) { 1129 if(_this._speedSelected == speed){ 1130 speedString.push({ action: "", label: speed + "x", color: _config.app.primaryColor || "#e7b816", callback: "_floatingmenu.hide();" }); 1131 }else{ 1132 speedString.push({ action: "", label: speed + "x", callback: "_player.speed.set(" + speed + ");_floatingmenu.hide();" }); 1133 } 1134 }) 1135 1136 speedString.push({ action: "", label: _system.label("close"), color: "#e95344", callback: "_floatingmenu.hide();" }); 1137 _floatingmenu.create(speedString, "<div class='p-20 t-gray title'>" + _system.label("playback-speed") + "</div>"); 1138 _floatingmenu.show(); 1139 }, 1140 1141 set: function (speed) { 1142 var _this = this; 1143 _this._speedSelected = speed; 1144 $("#speedButton").html(speed + "x"); 1145 _player._tag.playbackRate(speed); 1146 } 1147 }, 1148 1149 standard: { 1150 1151 show: function () { 1152 $('body').addClass("player-show"); 1153 }, 1154 1155 hide: function () { 1156 $('body').removeClass("player-show"); 1157 }, 1158 1159 toggle: function () { 1160 $('body').toggleClass("player-show"); 1161 }, 1162 1163 1164 1165 }, 1166 1167 fullscreen: { 1168 1169 show: function (is_playing, changeFormat) { 1170 var _this = this; 1171 return new Promise(function (resolve, reject) { 1172 _modal.show("player-full", _player._idDataPlaying).then(function () { 1173 _player._isInFullScreen = true; 1174 var data = _player._data[_player._idDataPlaying]; 1175 1176 _system.logEvent("event", { action: "Radio Companyplayer", "url": data['source-audio']}); 1177 1178 if (_player._tag && !_player._isPreparing) { 1179 _player.progressBar.update(); 1180 } else { 1181 if (data.type == "live") { 1182 $('#player-full div.bar div.legend.right').html(""); 1183 $('#player-full div.bar div.legend.left').html(""); 1184 } else if (data.duration !== undefined) { // podcast e playlists non hanno durata 1185 // $('#player-full div.bar div.legend.right').html(_system.durationToShow(data.duration)); 1186 // $('#player-full d\iv.bar div.legend.left').html(_system.durationToShow((_profile.user.log._data[_player._idDataPlaying] !== undefined ? _profile.user.log._data[_player._idDataPlaying].offset : 0) * data.duration / 100)); 1187 $('#player-full div.bar div.legend.right').html(""); 1188 $('#player-full div.bar div.legend.left').html(""); 1189 } else { 1190 $('#player-full div.bar div.legend.right').html(""); 1191 $('#player-full div.bar div.legend.left').html(""); 1192 1193 } 1194 $('#progressBar').attr("value", (_profile.user.log._data[_player._idDataPlaying] !== undefined ? _profile.user.log._data[_player._idDataPlaying].offset : 0)); 1195 $('player .bar div').css('width', (_profile.user.log._data[_player._idDataPlaying] !== undefined ? _profile.user.log._data[_player._idDataPlaying].offset : 0) + "%"); 1196 } 1197 1198 if (data !== undefined) { 1199 $('#player-full #player-title').html(data.title); 1200 1201 //Rerperisco ultimo meta registrato 1202 // _player.metadata.get(); 1203 //Nascondo il tasto live/start per la diretta 1204 1205 $('#player-full #player-description').css("-webkit-line-clamp", "0"); 1206 1207 if (data.type == "live") { 1208 1209 if (((_init._data["is_metadata"] && _player.metadata._vanityRendering == "main") || _player.metadata._vanityRendering != "main") && _player.metadata._vanityRendering !== null) { 1210 if(!_system.isNull(_player.metadata._image)){ 1211 $('#player-full #player-thumbnail').css("background-image", "url('" + _player.metadata._image + "')"); 1212 }else{ 1213 $('#player-full #player-thumbnail').css("background-image", "url('" + data.image + "')"); 1214 } 1215 if(!_system.isNull(_player.metadata._title) && !_system.isNull(_player.metadata._author)){ 1216 $('#player-full #player-abstract').html(_player.metadata._title + " - " + _player.metadata._author); 1217 }else{ 1218 $('#player-full #player-abstract').html(data.abstract); 1219 } 1220 } else { 1221 $('#player-full #player-thumbnail').css("background-image", "url('" + data.image + "')"); 1222 $('#player-full #player-abstract').html(data.abstract); 1223 } 1224 1225 $('#player-full #player-description').html(_system.removeTagsExceptionsPlayer(d
1225ata['description'])); 1226 $('#player-full #player-speakers').html(data['speakers'] !== undefined ? ("<div onclick='_player.fullscreen.hide()'>" + data['speakers'] + "</div>") : "") 1227 $('div.bar div.legend.right').html('LIVE'); 1228 $('[id=nextButton]').addClass("disabled"); 1229 $('[id=prevButton]').addClass("disabled"); 1230 if (_init._data.is_dvr_audio) { 1231 if (_player._deferred == true) { 1232 _player.showLive(); 1233 } else { 1234 _player.showStart(); 1235 } 1236 } else { 1237 _player.hideStartLive(); 1238 } 1239 $("#player-full #playlistButton").addClass("disabled"); 1240 $("#player-full #speedButton").addClass("disabled"); 1241 $("#player-full header").attr("episode-id", ""); 1242 } else { 1243 $('#player-full #player-abstract').html(data['program'] !== undefined ? ("<div onclick='_player.fullscreen.hide()'>" + data['program'] + "</div>") : data['abstract']) 1244 $('#player-full #player-description').html(_system.removeTagsExceptionsPlayer(data['description'])) 1245 $('#player-full #player-speakers').html(data['speakers'] !== undefined ? ("<div onclick='_player.fullscreen.hide()'>" + data['speakers'] + "</div>") : "") 1246 _player.checkNext(); 1247 _player.checkPrev(); 1248 // if (_player._tag) 1249 // $('div.bar div.legend.right').html(_system.secondsToProgress(_player._trackDuration)); 1250 _player.hideStartLive(); 1251 1252 if (!_system.isNull(data["episode_id"])) { 1253 $("#player-full header").attr("episode-id", data["episode_id"]) 1254 $("#player-full #playlistButton").removeClass("disabled"); 1255 1256 var playlistId = !_system.isNull(_profile.user.playlists._data) ? ((Object.keys(_profile.user.playlists._data).length == 1) ? Object.keys(_profile.user.playlists._data)[0] : "") : ""; 1257 var playlistStatus = !_system.isNull(_profile.user.playlists._data) ? ((Object.keys(_profile.user.playlists._data).length == 1) ? ((_profile.user.playlists._data[Object.keys(_profile.user.playlists._data)[0]]['items'] || []).includes(data["episode_id"]) ? "in-playlist" : "") : "") : ""; 1258 $("#player-full header").addClass(playlistStatus); 1259 $("#player-full header .playlist-on").attr("action", "_profile.user.playlists.showPlaylists('" + data["episode_id"] + "', $(this))") 1260 $("#player-full header .playlist-off").attr("action", "_profile.user.playlists.removeItem('" + data["episode_id"] + "', '" + playlistId + "', $(this))") 1261 1262 } else { 1263 $("#player-full #playlistButton").addClass("disabled"); 1264 } 1265 $("#player-full #speedButton").removeClass("disabled"); 1266 } 1267 1268 $("#video-js-object").css('pointer-events', 'all') 1269 $('.vjs-control-bar').css("display", "flex"); 1270 if (_player._format === "video") { 1271 $(".video-player-container").show(); 1272 $('.video-js').show(); 1273 $('video').show(); 1274 if (!$("#player-full").hasClass("fullscreen-video")){ 1275 $("#video-js-object").detach().appendTo(".video-player"); 1276 } 1277 if (_player._tag) { 1278 _player._tag.width($('#modal .body .video-player').innerWidth() || (screen.width > 981 ? 640 : screen.width)); 1279 _player._tag.height(($('#modal .body .video-player').innerWidth() || (screen.width > 981 ? 640 : screen.width)) * 9 / 16); 1280 } 1281 $("#player-thumbnail").hide(); 1282 // if (window.screen.orientation !== undefined) window.screen.orientation.unlock(); 1283 // if (window.screen.orientation !== undefined) window.screen.orientation.lock("portrait-primary"); 1284 $("#player-full #timerButton").addClass("disabled"); 1285 1286 } else if (_player._format === "audio") { 1287 $("#player-thumbnail").show(); 1288 $(".video-player-container").hide(); 1289 $('.video-js').hide(); 1290 $('video').hide(); 1291 if (window.screen.orientation !== undefined) window.screen.orientation.lock("portrait-primary"); 1292 $("#player-full #timerButton").removeClass("disabled"); 1293 1294 } 1295 1296 if (_system.lineCount($('#player-full #player-description')) > 3) { //fare funzione di controllo se supera 2 right 1297 $('#player-full .show-more-less').show(); 1298 $('#player-full #player-description').css("line-clamp", "4"); 1299 $('#player-full #player-description').css("-webkit-line-clamp", "4"); 1300 } else { 1301 $('#player-full .show-more-less').hide(); 1302 $('#player-full #player-description').css("line-clamp", "0"); 1303 $('#player-full #player-description').css("-webkit-line-clamp", "0"); 1304 } 1305 1306 if (_player._deferred == true && _player._streamType == "live") { 1307 //Controllo se necessario aggiornare il descrittivo di differita con indicazione tempo 1308 _player.progressBar.updateDescriptionPlayer(); 1309 } 1310 1311 /* 1312 $('.actions #prefsButton').attr('action', "_profile.user.favorites.toggle('" + data['program_id'] + "')"); 1313 if (data.type == "program") { 1314 $('.actions #prefsButton').removeClass("disabled"); 1315 } else { 1316 $('.actions #prefsButton').addClass("disabled"); 1317 } 1318 */ 1319 1320 if (data['is_interactive'] != true) { 1321 $('#header-player #chatButton').addClass("disabled"); 1322 } else { 1323 $('#header-player #chatButton').removeClass("disabled"); 1324 // $('#header-player #chatButton').attr('action', "_player.fullscreen.hide();"); 1325 // $('#header-player #chatButton').parent().attr('href', _system.createLink("chats/" + data['vanityurlProgram'])); 1326 } 1327 1328 if (Object.keys(data).includes('source-video') && !_system.isNull(data['source-video']) && Object.keys(data).includes('source-audio') && !_system.isNull(data['source-audio'])) { 1329 $(".videoAudioSelector").show() 1330 } else { 1331 $(".videoAudioSelector").hide() 1332 } 1333 1334 if (_player._isPlaying == 1 && _player._idDataPlaying !== undefined) { 1335 $('#player-full').addClass("is-playing"); 1336 } 1337 1338 if (data['program_id'] in _profile.user.favorites._data) { 1339 $('#player-full .actions .prefs span').html('favorite'); 1340 $('#player-full .actions .prefs small').text(_system.label("prefs-remove")); 1341 } else { 1342 $('#player-full .actions .prefs span').html('favorite_border'); 1343 $('#player-full .actions .prefs small').text(_system.label("prefs-add")); 1344 } 1345 //da verificare modifica 1346 $('#player-full .action-button.play').attr('action', '_player.play("' + _player._idDataPlaying + '", "' + _player._idDataPlaylist + '")'); 1347 1348 _toolbar.hide(); 1349 _advertising.refreshPlayerBanner(); 1350 _player.standard.hide(); 1351 } 1352 resolve() 1353 }); 1354 }) 1355 }, 1356 1357 logOpenModal: function() { 1358 var playerUri = ""; 1359 if (_player._data[_player._idDataPlaying].type == "live") { 1360 playerUri = "play/live"; 1361 } else if (_player._data[_player._idDataPlaying].type == "CONTAINER") { 1362 playerUri = "play/" + (_player._data[_player._idDataPlaying].href == "" ? "" : _player._data[_player._idDataPlaying].href); 1363 } else if (_player._data[_player._idDataPlaying].type == "embedded") { 1364 playerUri = "play/programmi/" + _system.formatVanity((_player._data[_player._idDataPlaying].title == "" ? "rubrica" : _player._data[_player._idDataPlaying].title)) 1365 } 1366 if (playerUri != "") { 1367 _system.logEvent("view", { view: playerUri }); 1368 } 1369 }, 1370 1371 hide: function () { 1372 _player._isInFullScreen = false;
1373 _toolbar.show(); 1374 _player.standard.show(); 1375 _modal.hide(); 1376 //if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 1377 if (_player._format === "video") { 1378 $("#video-js-object").detach().appendTo('#player-light thumbnail') 1379 $("#video-js-object").css('pointer-events', 'none'); 1380 $('.vjs-control-bar').css("display", "none"); 1381 if (_player._tag) { 1382 _player._tag.width(screen.width > 981 ? 210 : 50); 1383 _player._tag.height(screen.width > 981 ? 120 : 50); 1384 } 1385 } 1386 1387 if (_player._streamType == "live" && (((_init._data["is_metadata"] && _player.metadata._vanityRendering == "main") || _player.metadata._vanityRendering != "main") && _player.metadata._vanityRendering !== null)) { 1388 if (!_system.isNull(_player.metadata._author)) { 1389 if (_system.isNull(_player.metadata._title)) { 1390 $('#player-light description').html(_player.metadata._author); 1391 } else { 1392 $('#player-light description').html(_player.metadata._title + " - " + _player.metadata._author); 1393 } 1394 } else { 1395 $('#player-light description').html(_system.label("live")); 1396 } 1397 1398 if (!_system.isNull(_player.metadata._image)) { 1399 $('#player-light thumbnail').css('background-image', "url('" + _player.metadata._image + "')"); 1400 } 1401 } 1402 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 1403 }, 1404 1405 update: function (is_playing) { 1406 var data = _player._data[_player._idDataPlaying]; 1407 if (data !== undefined) { 1408 if (_player._dvrRequested === null) { 1409 $('#player-full #player-title').html(data.title); 1410 if(data.type == "live") { 1411 if (((_init._data["is_metadata"] && _player.metadata._vanityRendering == "main") || _player.metadata._vanityRendering != "main") && _player.metadata._vanityRendering !== null) { 1412 if(!_system.isNull(_player.metadata._image)){ 1413 $('#player-full #player-thumbnail').css("background-image", "url('" + _player.metadata._image + "')"); 1414 }else{ 1415 $('#player-full #player-thumbnail').css("background-image", "url('" + data.image + "')"); 1416 } 1417 if(!_system.isNull(_player.metadata._title) && !_system.isNull(_player.metadata._author)){ 1418 $('#player-full #player-abstract').html(_player.metadata._title + " - " + _player.metadata._author); 1419 }else{ 1420 $('#player-full #player-abstract').html(data.abstract); 1421 } 1422 } else { 1423 $('#player-full #player-abstract').html(data.abstract); 1424 $('#player-full #player-thumbnail').css("background-image", "url('" + data.image + "')"); 1425 } 1426 }else{ 1427 $('#player-full #player-thumbnail').css("background-image", "url('" + data.image + "')"); 1428 $('#player-full #player-abstract').html(data['program'] !== undefined ? ("<div onclick='_player.fullscreen.hide()'>" + data['program'] + "</div>") : data['abstract']) 1429 } 1430 1431 $('#player-full #player-speakers').html(data['speakers'] !== undefined ? ("<div onclick='_player.fullscreen.hide()'>" + data['speakers'] + "</div>") : "") 1432 if (data.type != 'live') { 1433 $('#player-full #player-description').css("-webkit-line-clamp", "0"); 1434 $('#player-full #player-description').html(_system.removeTagsExceptionsPlayer(d
1434ata['description'])); 1435 } 1436 } 1437 if (_system.lineCount($('#player-full #player-description')) > 3) { //fare funzione di controllo se supera 2 right 1438 $('#player-full .show-more-less').show(); 1439 $('#player-full #player-description').css("line-clamp", "4"); 1440 $('#player-full #player-description').css("-webkit-line-clamp", "4"); 1441 } else { 1442 $('#player-full .show-more-less').hide(); 1443 $('#player-full #player-description').css("line-clamp", "0"); 1444 $('#player-full #player-description').css("-webkit-line-clamp", "0"); 1445 } 1446 // _player.progressBar.update(); 1447 $("#player-full header").removeClass("in-playlist"); 1448 if (_player._streamType != "live") { 1449 $('div.bar div.legend.right').html(_system.secondsToProgress(_player._trackDuration)); 1450 _player.checkNext(); 1451 _player.checkPrev(); 1452 1453 if (!_system.isNull(data["episode_id"])) { 1454 $("#player-full header").attr("episode-id", data["episode_id"]) 1455 $("#player-full #playlistButton").removeClass("disabled"); 1456 1457 var playlistId = !_system.isNull(_profile.user.playlists._data) ? ((Object.keys(_profile.user.playlists._data).length == 1) ? Object.keys(_profile.user.playlists._data)[0] : "") : ""; 1458 var playlistStatus = !_system.isNull(_profile.user.playlists._data) ? ((Object.keys(_profile.user.playlists._data).length == 1) ? ((_profile.user.playlists._data[Object.keys(_profile.user.playlists._data)[0]]['items'] || []).includes(data["episode_id"]) ? "in-playlist" : "") : "") : ""; 1459 $("#player-full header").addClass(playlistStatus); 1460 $("#player-full header .playlist-on").attr("action", "_profile.user.playlists.showPlaylists('" + data["episode_id"] + "', $(this))") 1461 $("#player-full header .playlist-off").attr("action", "_profile.user.playlists.removeItem('" + data["episode_id"] + "', '" + playlistId + "', $(this))") 1462 1463 } else { 1464 $("#player-full #playlistButton").addClass("disabled"); 1465 } 1466 $("#player-full #speedButton").removeClass("disabled"); 1467 } else { 1468 $("#player-full #playlistButton").addClass("disabled"); 1469 $("#player-full #speedButton").addClass("disabled"); 1470 $("#player-full header").attr("episode-id", ""); 1471 } 1472 1473 if (is_playing == 1 && _player._idDataPlaying !== undefined) { 1474 $('#player-full').addClass("is-playing"); 1475 } 1476 1477 1478 if (Object.keys(data).includes('source-video') && !_system.isNull(data['source-video']) && Object.keys(data).includes('source-audio') && !_system.isNull(data['source-audio'])) { 1479 $(".videoAudioSelector").show() 1480 1481 if (_player._format === "video") { 1482 $(".videoAudioSelector ul li[page='2']").addClass("selected"); 1483 $(".videoAudioSelector ul li[page='1']").removeClass("selected"); 1484 } else { 1485 $(".videoAudioSelector ul li[page='1']").addClass("selected"); 1486 $(".videoAudioSelector ul li[page='2']").removeClass("selected"); 1487 } 1488 } else { 1489 $(".videoAudioSelector").hide() 1490 } 1491 1492 if (_player._format === "video") { 1493 $(".video-player-container").show(); 1494 $('.video-js').show(); 1495 $('video').show(); 1496 $("#player-thumbnail").hide(); 1497 // if (window.screen.orientation !== undefined) window.screen.orientation.unlock(); 1498 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 1499 $("#player-full #timerButton").addClass("disabled"); 1500 1501 } else if (_player._format === "audio") { 1502 $("#player-thumbnail").show(); 1503 $(".video-player-container").hide(); 1504 $('.video-js').hide(); 1505 $('video').hide(); 1506 // if (window.screen.orientation !== undefined) window.screen.orientation.lock('portrait-primary'); 1507 $("#player-full #timerButton").removeClass("disabled"); 1508 } 1509 1510 1511 $('#player-full .action-button.play').attr('action', '_player.play("' + _player._idDataPlaying + '", "' + _player._idDataPlaylist + '")'); 1512 //$(".videoAudioSelector ul li[page='1']").parent().attr("href", _system.createLink('live/audio')); 1513 $(".videoAudioSelector ul li[page='1']").attr("action", 'if(_player._format != "audio"){if(_player.streamType != "live") {_player._changeFormat = true;} _player._srcPlaying=""; _player.play("' + _player._idDataPlaying + '", "' + _player._idDataPlaylist + '", "audio"); }'); 1514 //$(".videoAudioSelector ul li[page='2']").parent().attr("href", _system.createLink('live/video')); 1515 $(".videoAudioSelector ul li[page='2']").attr("action", 'if(_player._format != "video"){if(_player.streamType != "live") {_player._changeFormat = true;} _player._srcPlaying=""; _player.play("' + _player._idDataPlaying + '", "' + _player._idDataPlaylist + '", "video"); }'); 1516 _toolbar.hide(); 1517 _player.standard.hide(); 1518 } 1519 } 1520 1521 }, 1522 1523 progressBar: { 1524 1525 timeDeferred: null, 1526 1527 set: function (value) { 1528 if (_player._adPlaying) return; 1529 if (_player._deferred == true || _player._streamType != 'live') { 1530 if (_player._streamType == "live") { 1531 if (value >= 100) { 1532 _player.startLiveToggle('live'); 1533 } else { 1534 _player._deferred = true; 1535 $('div.bar div.legend.left').html("-" + _system.secondsToProgress(_player._trackDuration - (value * _player._trackDuration / 100))); 1536 if (_player._tag === window.ExoPlayer) { 1537 _player._tag.currentTime(value); 1538 } else { 1539 _player._tag.currentTime(value * _player._trackDuration / 100); 1540 } 1541 _player.showLive(); 1542 } 1543 } else { 1544 $('div.bar div.legend.left').html(_system.secondsToProgress(value * _player._trackDuration / 100)); 1545 if (_player._tag === window.ExoPlayer) { 1546 _player._tag.currentTime(value); 1547 } else { 1548 _player._tag.currentTime(value * _player._trackDuration / 100); 1549 } 1550 if (_player.countdownTimer._timer !== null && _player.countdownTimer._endOfEpisode == true) { 1551 if (_player._trackDuration > 0) { 1552 _player.countdownTimer.start(((100 - value) * _player._trackDuration / 100)); 1553 } else { 1554 setTimeout( 1555 function () { 1556 if (_player._trackDuration > 0) { 1557 _player.countdownTimer.start(((100 - value) * _player._trackDuration / 100)); 1558 } 1559 }, 2000 1560 ) 1561 } 1562 } 1563 }
1564 _player.progressBar.update(); 1565 } else { 1566 if (_player._format == "audio") { 1567 if (_init._data.is_dvr_audio) { 1568 _player.showLive(); 1569 _player._deferred = true; 1570 _player._dvrRequested = value; 1571 _player._srcPlaying = ""; 1572 _player.play(_player._idDataPlaying, _player._idDataPlaylist, "audio"); 1573 } else { 1574 //_toastmessage.show('533', "warning"); 1575 return; 1576 } 1577 } else if (_player._format == "video") { 1578 if (_init._data.is_dvr_video) { 1579 _player.showLive(); 1580 _player._deferred = true; 1581 _player._dvrRequested = value; 1582 _player._srcPlaying = ""; 1583 _player.play(_player._idDataPlaying, _player._idDataPlaylist, "video"); 1584 } else { 1585 //_toastmessage.show('534', "warning"); 1586 return; 1587 } 1588 } 1589 } 1590 }, 1591 1592 update: function () { 1593 var _this = this; 1594 var value; 1595 if (_player._progressInterval == 0 || _player._isPaused) { 1596 return; 1597 } 1598 if (_player._deferred != true) { 1599 if (_player._streamType == "live") { //live 1600 value = "100"; 1601 $('div.bar div.legend.left').html("") 1602 $('[id=forwardButton]').addClass("disabled"); 1603 } else { 1604 value = (_player._progress * 100) / _player._trackDuration 1605 // $('#progressBar').attr("value", value) //dopo aver schiacciato il progress bar non aggiorna correttamente lo slider 1606 $('article[player-id="' + _player._idDataPlaying + '"] .bar div').css('width', value + "%"); //solo quando metto su firebase 1607 $('div.bar div.legend.left').html(_system.secondsToProgress(_player._progress)); 1608 $('div.bar div.legend.right').html(_system.secondsToProgress(_player._trackDuration)); 1609 if(_player._adPlaying == true){ 1610 $('[id=forwardButton]').addClass("disabled"); 1611 $('[id=speedButton]').addClass("disabled"); 1612 }else{ 1613 $('[id=forwardButton]').removeClass("disabled"); 1614 $('[id=speedButton]').removeClass("disabled"); 1615 } 1616 } 1617 } else { 1618 if (_player._dvrRequested === null) { 1619 value = (_player._progress * 100) / _player._trackDuration; 1620 if (value > 0) { 1621 if ((_player._trackDuration - _player._progress) < 0 && _player._progress < _player._trackDuration) { 1622 _player._deferred = false; 1623 $('div.bar div.legend.left').html(""); 1624 $('div.bar div.legend.right').html('LIVE'); 1625 } else { 1626 // if (_player._progress < _player._trackDuration) { 1627 if (Math.round(_player._trackDuration - (_player._progress)) > 0) { 1628 $('div.bar div.legend.left').html("-" + _system.secondsToProgress(Math.round(_player._trackDuration - (_player._progress)))); 1629 } 1630 1631 if ((_player._format == "audio" && _init._data["is_dvr_audio"] || _player._format == "video" && _init._data["is_dvr_video"])) { 1632 $('[id=forwardButton]').removeClass("disabled"); 1633 } 1634 if (_this.timeDeferred != Math.trunc((_player._trackDuration - _player._progress) / 60)) { 1635 _this.updateDescriptionPlayer(); 1636 } 1637 // } 1638 } 1639 } 1640 1641 } else { 1642 if (_player._dvrRequested == -10) { 1643 value = 100; 1644 } else { 1645 value = _player._dvrRequested; 1646 } 1647 } 1648 } 1649 1650 if (_player._streamType == "live") { 1651 if ((_player._format == "audio" && _init._data["is_dvr_audio"] || _player._format == "video" && _init._data["is_dvr_video"])) { 1652 if (_player._progress < 1) { 1653 $('[id=backwardButton]').addClass("disabled"); 1654 } else { 1655 $('[id=backwardButton]').removeClass("disabled"); 1656 } 1657 } else { 1658 $('[id=backwardButton]').addClass("disabled"); 1659 } 1660 } else { 1661 if (_player._progress < 1) { 1662 $('[id=backwardButton]').addClass("disabled"); 1663 } else { 1664 $('[id=backwardButton]').removeClass("disabled"); 1665 } 1666 } 1667 1668 if (_player._changeFormat !== true && value > 0) { 1669 _player._data[_player._idDataPlaying]['offset'] = value; 1670 } 1671 $('player .bar div').css('width', value + "%"); 1672 // $("#progressBar").attr("value", value); 1673 if ($('#modal #player-full').length) { 1674 if (value > 0) { 1675 if (_player._isBarOnPressed == false) { 1676 document.getElementById('progressBar').value = value; 1677 } 1678 } 1679 } 1680 }, 1681 1682 updateDescriptionPlayer: function () { 1683 var _this = this; 1684 if (_player._trackDuration - (_player._progress) > 0) { 1685 _this.timeDeferred = Math.trunc((_player._trackDuration - _player._progress) / 60); 1686 if (_this.timeDeferred == 1) { 1687 var description = _system.label("deferred-by") + " " + _this.timeDeferred + " " + _system.label("min"); 1688 } else if (_this.timeDeferred == 0) { 1689 var description = _system.label("deferred-by-less-minute"); 1690 } else { 1691 var description = _system.label("deferred-by") + " " + _this.timeDeferred + " " + _system.label("mins"); 1692 } 1693 $('player description, #player-description').html(description); 1694 // _player.notification.create(_config.app.radio.name, _system.label("live"), _init._data.cover || _config.app.radio.logo); 1695 } 1696 }, 1697 1698 }, 1699 1700 playlists: { 1701 1702 _data: [], 1703 1704 create: function (uid) { 1705 this._data[uid] = []; 1706 }, 1707 1708 add: function (uidPlaylist, uidMedia, order) { 1709 if (order == "desc") { 1710 this._data[uidPlaylist].unshift(uidMedia); 1711 } else {
1712 this._data[uidPlaylist].push(uidMedia); 1713 } 1714 }, 1715 1716 remove: function (uidPlaylist, uidMedia) { 1717 this._data[uidPlaylist].splice(this._data[uidPlaylist].indexOf(uidMedia), 1); 1718 }, 1719 1720 nextId: function () { 1721 if (_player._idDataPlaylist === undefined || _player._idDataPlaylist === null) return undefined; 1722 var actualIndex = this._data[_player._idDataPlaylist].indexOf(_player._idDataPlaying); 1723 return this._data[_player._idDataPlaylist][actualIndex + 1]; 1724 }, 1725 1726 prevId: function () { 1727 if (_player._idDataPlaylist === undefined || _player._idDataPlaylist === null) return undefined; 1728 var actualIndex = this._data[_player._idDataPlaylist].indexOf(_player._idDataPlaying); 1729 return this._data[_player._idDataPlaylist][actualIndex - 1]; 1730 }, 1731 1732 next: function () { 1733 if (_player.playlists.nextId() !== undefined) { 1734 _player.play(_player.playlists.nextId(), _player._idDataPlaylist); 1735 // $('[id=prevButton]').removeClass("disabled"); 1736 // if (_player.playlists.nextId() === undefined) { 1737 // $('[id=nextButton]').addClass("disabled"); 1738 // } else { 1739 // $('[id=nextButton]').removeClass("disabled"); 1740 // } 1741 } 1742 }, 1743 1744 prev: function () { 1745 if (_player.playlists.prevId() !== undefined && _player._streamType != "live") { 1746 _player.play(_player.playlists.prevId(), _player._idDataPlaylist); 1747 // $('[id=nextButton]').removeClass("disabled"); 1748 // if (_player.playlists.prevId() === undefined) { 1749 // $('[id=prevButton]').addClass("disabled"); 1750 // } else { 1751 // $('[id=prevButton]').removeClass("disabled"); 1752 // } 1753 } 1754 } 1755 }, 1756 1757 notification: { 1758 _musicControls: null, 1759 1760 create: function (title, description, image) { 1761 var _this = this; 1762 { 1763 if (_this._musicControls !== null) { 1764 _this._musicControls.destroy(); 1765 } 1766 _this._musicControls = MusicControls; 1767 _this._musicControls.subscribe(this.events); 1768 _this._musicControls.listen(); 1769 if (_player._streamType == "live") { 1770 var options = { 1771 track: title, 1772 artist: _system.removeTags(description), 1773 cover: image, 1774 isPlaying: true, 1775 dismissable: true, 1776 hasPrev: false, // show previous button, optional, default: true 1777 hasNext: false, 1778 hasClose: false, 1779 ticker: "Now playing " + title, 1780 playIcon: 'play_circle', 1781 pauseIcon: 'pause_circle', 1782 // notificationIcon: "icon" 1783 } 1784 } else { 1785 var options = { 1786 track: title, 1787 artist: _system.removeTags(description), 1788 cover: image, 1789 isPlaying: true, 1790 hasPrev: (_player.playlists.prevId() !== undefined ? true : false), // show previous button, optional, default: true 1791 hasNext: (_player.playlists.nextId() !== undefined ? true : false), 1792 dismissable: true, 1793 hasClose: false, 1794 ticker: "Now playing " + title, 1795 playIcon: 'play_circle', 1796 pauseIcon: 'pause_circle', 1797 prevIcon: 'skip_prev', 1798 nextIcon: 'skip_next', 1799 // notificationIcon: "icon" 1800 } 1801 } 1802 _this._musicControls.create(options); 1803 setTimeout(function () { 1804 _player.notification._musicControls.updateIsPlaying(true); 1805 }, 1000) 1806 } 1807 }, 1808 1809 events: function (action) { 1810 const message = JSON.parse(action).message; 1811 console.log("events: " + message); 1812 switch (message) { 1813 case 'music-controls-next': 1814 _player.playlists.next(); 1815 break; 1816 case 'music-controls-previous': 1817 _player.playlists.prev(); 1818 break; 1819 case 'music-controls-pause': 1820 _player.pause(); 1821 _player.notification._musicControls.updateIsPlaying(false); 1822 break; 1823 case 'music-controls-play': 1824 _player.play(_player._idDataPlaying); 1825 _player.notification._musicControls.updateIsPlaying(true); 1826 break; 1827 case 'music-controls-destroy': 1828 _player.notification._musicControls.destroy(); 1829 // _player.stop(); 1830 break; 1831 case 'music-controls-toggle-play-pause': 1832 if (_player._isPlaying) { 1833 _player.pause(); 1834 _player.notification._musicControls.updateIsPlaying(false); 1835 } else { 1836 _player.play(_player._idDataPlaying); 1837 _player.notification._musicControls.updateIsPlaying(true); 1838 } 1839 break; 1840 // case 'music-controls-seek-to': 1841 // var seekToInSeconds = parseInt(JSON.parse(action).position); 1842 // MusicControls.updateElapsed({ 1843 // elapsed: seekToInSeconds, 1844 // isPlaying: true 1845 // }); 1846 // if(_player._tag === window.ExoPlayer){ 1847 // _player._tag.currentTime((100 * (seekToInSeconds)) / _player._trackDuration); 1848 // }else{ 1849 // _player._tag.currentTime(seekToInSeconds); 1850 // } 1851 // break; 1852 default: 1853 break; 1854 } 1855 } 1856 }, 1857 1858 //create a countdown timer for the player 1859 countdownTimer: { 1860 _timer: null, 1861 _duration: null, 1862 _remainingTime: null, 1863 _endOfEpisode: false, 1864 1865 showMenu: function () { 1866 // if (!_profile.isLogged()) { 1867 // _toastmessage.show('513', 'warning'); 1868 // return; 1869 // } 1870 1871 var _this = this; 1872 var durationsString = []; 1873 // var durations = [5, 10, 15, 30, 45, 60]; 1874 var durations = [15, 30, 45, 60]; 1875 1876 for (var i = 0; i < durations.length; i++) { 1877 durationsString.push({ action: "", label: durations[i] + " " + _system.label("mins"), callback: "_player.countdownTimer._endOfEpisode = false; _player.countdownTimer.start(" + durations[i] * 60 + "); _floatingmenu.hide();" }); 1878 } 1879 if (_player._streamType != "live") { 1880 durationsString.push({ action: "", label: _system.label("end-of-episode"), callback: "_player.countdownTimer.start(" + parseInt(_player._trackDuration - _player._progress) + "); _player.countdownTimer._endOfEpisode = true; _floatingmenu.hide();" }); 1881 } 1882 if (_this._timer !== null) { 1883 durationsString.push({ action: "", label: _system.label("remove-timer"), callback: "_player.countdownTimer.stop(); _floatingmenu.hide();" }); 1884 durationsString.push({ action: "", label: _system.label("close"), c
1884olor: "#e95344", callback: "_floatingmenu.hide();" }); 1885 if (Math.floor(_this._remainingTime / 60) == 1) { 1886 _floatingmenu.create(durationsString, "<div class='p-20 t-gray title'>" + _system.label("sleep-timer") + "<br><span class='t-mini'>" + Math.floor(_this._remainingTime / 60) + " " + _system.label("min-left") + "</span></div>"); 1887 } else { 1888 _floatingmenu.create(durationsString, "<div class='p-20 t-gray title'>" + _system.label("sleep-timer") + "<br><span class='t-mini'>" + Math.floor(_this._remainingTime / 60) + " " + _system.label("mins-left") + "</span></div>"); 1889 } 1890 } else { 1891 durationsString.push({ action: "", label: _system.label("close"), color: "#e95344", callback: "_floatingmenu.hide();" }); 1892 _floatingmenu.create(durationsString, "<div class='p-20 t-gray title'>" + _system.label("sleep-timer") + "</div>"); 1893 } 1894 _floatingmenu.show(); 1895 }, 1896 1897 start: function (duration = 0) { 1898 duration = parseInt(duration) 1899 console.log("[TIMER] " + _system.timeNow() + " Start!"); 1900 var _this = this; 1901 if (duration != 0) { 1902 _this._duration = duration; 1903 } 1904 if (_this._timer !== null) { 1905 _this._timer.stop(); 1906 _this._timer = null; 1907 } 1908 _this._timer = window.ExoPlayer.timer; 1909 1910 _this._timer.start(duration, 1911 function (json) { 1912 if (json["type"] == "onStart") { 1913 $("#player-full .actions #timerButton span").html("timer_off"); 1914 if (!_player._isPlaying) { 1915 _player.countdownTimer.pause(); 1916 } 1917 } else if (json["type"] == "onTick") { 1918 _player.countdownTimer._remainingTime = json["secondsRemaining"]; 1919 } else { 1920 console.log("Timer stopped!"); 1921 _player.countdownTimer.stop(); 1922 } 1923 }, 1924 function (error) { 1925 console.error("Error: " + error); 1926 } 1927 ); 1928 1929 }, 1930 1931 pause: function () { 1932 console.log("[TIMER] " + _system.timeNow() + " Pause!"); 1933 var _this = this; 1934 if (_this._timer !== null) { 1935 _this._timer.pause(); 1936 } 1937 }, 1938 1939 resume: function () { 1940 console.log("[TIMER] " + _system.timeNow() + " Resume!"); 1941 var _this = this; 1942 if (_this._timer !== null) { 1943 _this._timer.start(); 1944 } 1945 }, 1946 1947 stop: function () { 1948 console.log("[TIMER] " + _system.timeNow() + " Stop!"); 1949 var _this = this; 1950 if (_this._timer !== null) { 1951 _this._timer.stop(); 1952 _this._timer = null; 1953 _this._duration = null; 1954 _this._endOfEpisode = false; 1955 $("#player-full .actions #timerButton span").html("timer"); 1956 } 1957 }, 1958 }, 1959 1960 metadata: { 1961 _author: null, 1962 _title: null, 1963 _image: null, 1964 _ref: null, 1965 _vanityRendering: null, 1966 1967 init: function (vanity) { 1968 var _this = this; 1969 _this.remove(); 1970 _this._vanityRendering = vanity; 1971 var connectedRef = firebase.database().ref('.info/connected'); 1972 connectedRef.off("value"); 1973 connectedRef.on('value', (snap) => { 1974 var status = snap.val(); 1975 console.log("FIREBASE CONNECTION: " + status) 1976 if (status === true) { 1977 if(_player.metadata._vanityRendering == "main" && !_init._data['is_metadata']){ 1978 _player.notification.create($('#player-light .title').html(), _system.label("live"), _player._data[_player._idDataPlaying].image || _init._data.cover || _config.app.radio.logo); 1979 return; 1980 } 1981 _player.metadata._ref = firebase.database().ref("groups/" + _config.app.radio.group + "/radios/" + _player._data[_player._idDataPlaying]["radio_id"] + "/logs/streaming/" + _player.metadata._vanityRendering); 1982 _player.metadata._ref.on('value', (snapshot) => { 1983 var data = snapshot.val(); 1984 if (data !== null) { 1985 var text = data['author_title'] 1986 text = text.split('-'); 1987 _this._author = text[0].trim(); 1988 if (text.length == 2) { 1989 _this._title = text[1].trim(); 1990 } else if (text.length > 2) { 1991 _this._title = ""; 1992 for (var i = 1; i < text.length; i++) { 1993 _this._title += " " + text[i]; 1994 } 1995 } else if (text.lenght == 1) { 1996 _this._title = text[0].trim(); 1997 } else { 1998 _this._title = null; 1999 } 2000 _this._image = data['image']; 2001 }else{ 2002 _this._author = ""; 2003 _this._title = ""; 2004 _this._image = ""; 2005 } 2006 _this.show(); 2007 }); 2008 } 2009 }) 2010 }, 2011 2012 show: function () { 2013 var _this = this; 2014 if (_player._deferred === false && _player._streamType === "live") { 2015 if (!_system.isNull(_this._author)) { 2016 if (_system.isNull(_this._title)) { 2017 $('#player-light description').html(_this._author); 2018 $('#player-full #player-abstract').html(_this._author); 2019 } else { 2020 $('#player-light description').html(_this._title + " - " + _this._author); 2021 $('#player-full #player-abstract').html(_this._title + " - " + _this._author); 2022 } 2023 // _player.notification.create($('#player-light .title').html(), _this._title + " - " + _this._author, _this._image || _init._data.cover || _config.app.radio.logo); 2024 // _player.notification.create($('#player-light .title').html(), _system.label("live"), _init._data.cover || _config.app.radio.logo); 2025 } else { 2026 $('player description').html(_system.label("live")); 2027 $('#player-full #player-abstract').html(_system.label("live")); 2028 // _player.notification.create($('#player-light .title').html(), _system.label("live"), _init._data.cover || _config.app.radio.logo); 2029 // _player.notification.create(_player._data[_player._idDataPlaying].title, _system.label("live"), _player._data[_player._idDataPlaying].image || _init._data.cover || _config.app.radio.logo); 2030 } 2031 _player.notification.create($('#player-light .title').html(), _system.label("live"), _player._data[_player._idDataPlaying].image || _init._data.cover || _config.app.radio.logo); 2032 2033 if (!_system.isNull(_this._image)) { 2034 $('#player-light thumbnail').css('background-image', "url('" + _this._image + "')"); 2035 $('#player-full #player-thumbnail').css("background-image", "url('" + _this._image + "')"); 2036 }else{ 2037 $('#player-light thumbnail').css('background-image', "url('" + _player._data[_player._idDataPlaying].image + "')"); 2038 $('#player-full #player-thumbnail').css("background-image", "url('" + _player._data[_player._idDataPlaying].image + "')"); 2039 } 2040 2041 } 2042 }, 2043 2044 remove: function () { 2045 var _this = this; 2046 _this._vanityRendering = null; 2047 if (_this._ref !== null) { 2048 _this._ref.off("value"); 2049 } 2050 } 2051 2052 }, 2053 2054 // advertising: { 2055 // _companionBannerSrc: null, 2056 2057 // getImgSrc: function (url) { 2058 // $.ajax({ 2059 // url: url, 2060 // success: function (data) { 2061 // var div = document.createElement('div'); 2062 // div.innerHTML = data; 2063 // var img = div.getElementsByTagName('img')[0]; 2064 // if (_system.isNull(img)) return; 2065 // _player.advertising._companionBannerSrc = img.src; 2066 // _player.advertising.render(); 2067 // }, 2068 // error: function (e) { 2069 // console.log(e); 2070 // } 2071 // }); 2072 // }, 2073 2074 // render: function () { 2075 // var _this = this; 2076 // // $('div.banner-area.musthead').html('<img src="' + _this._companionBannerSrc + '" />'); 2077 2078 // } 2079 // } 2080 2081}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.