Update serpentine's embed code V06.003
authorymh <ymh.work@gmail.com>
Fri, 21 Sep 2018 13:59:11 +0200
changeset 1450 8066d700510c
parent 1449 f337cfef91da
child 1451 4ebd2ab9ea18
Update serpentine's embed code
web/marathon-serpentine-2018/config.php
web/marathon-serpentine-2018/reloader.php
--- a/web/marathon-serpentine-2018/config.php	Fri Sep 21 13:58:48 2018 +0200
+++ b/web/marathon-serpentine-2018/config.php	Fri Sep 21 13:59:11 2018 +0200
@@ -1,27 +1,20 @@
 <?php
 
-$youtube_code_list = [
-    // [new DateTime('2018-09-20T12:43:00Z'),new DateTime('2018-09-20T13:10:00Z'), 'eqB0gIALuUs'],
-    [new DateTime('2018-09-22T08:30:00Z'), new DateTime('2018-09-22T12:25:00Z'), 'eqB0gIALuUs'],
-    [new DateTime('2018-09-22T12:25:00Z'), new DateTime('2018-09-22T20:30:00Z'), 'iHygIOIkZ0A'],
-    [new DateTime('2018-09-23T07:30:00Z'), new DateTime('2018-09-23T16:30:00Z'), 'iHygIOIkZ0A'],
+$embed_code_list = [
+    [new DateTime('2018-09-22T08:30:00Z'), new DateTime('2018-09-22T12:25:00Z'), '<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/eqB0gIALuUs?autoplay=1\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" modestbranding=1 allowfullscreen></iframe>'],
+    [new DateTime('2018-09-22T12:25:00Z'), new DateTime('2018-09-22T20:30:00Z'), '<iframe id="ls_embed_1537527835" src="https://livestream.com/accounts/27752410/events/8379051/player?width=560&height=315&enableInfoAndActivity=true&defaultDrawer=&autoPlay=true&mute=false" width="560" height="315" frameborder="0" scrolling="no" allowfullscreen> </iframe>'],
+    [new DateTime('2018-09-23T07:30:00Z'), new DateTime('2018-09-23T16:30:00Z'), '<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/iHygIOIkZ0A?autoplay=1\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" modestbranding=1 allowfullscreen></iframe>'],
 ];
 
-$youtube_code = null;
+$islive_embed = null;
 $current_time = new DateTime();
 
-foreach ($youtube_code_list as $time_entry) {
+foreach ($embed_code_list as $time_entry) {
     if($current_time >= $time_entry[0] &&  $current_time <= $time_entry[1]) {
-        $youtube_code = $time_entry[2];
+        $islive_embed = $time_entry[2];
         break;
     }
 }
-$islive_embed = null;
-if(!is_null($youtube_code)) {
-    $islive_embed = "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/${youtube_code}?autoplay=1\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" modestbranding=1 allowfullscreen></iframe>";
-}
-
-
 
 $config = array(
     'rep' => basename(__DIR__),
--- a/web/marathon-serpentine-2018/reloader.php	Fri Sep 21 13:58:48 2018 +0200
+++ b/web/marathon-serpentine-2018/reloader.php	Fri Sep 21 13:59:11 2018 +0200
@@ -2,17 +2,17 @@
 include_once('./config.php');
 header("Content-type: application/x-javascript");
 ?>
-var startYoutubeCode = "<?php echo($youtube_code ? $youtube_code : '') ?>";
+var startEmbedCode = "<?php echo($islive_embed ? $islive_embed : '') ?>";
 
-function getCurrentYoutubeCode() {
+function getCurrentEmbedCode() {
     var resCode = null;
-    var youtubeCodeList = [
-    <?php foreach ($youtube_code_list as $time_entry): ?>
+    var embedCodeList = [
+    <?php foreach ($embed_code_list as $time_entry): ?>
         [<?php echo($time_entry[0]->getTimestamp() * 1000); ?>, <?php echo($time_entry[1]->getTimestamp() * 1000); ?>, "<?php echo($time_entry[2]);?>"],
     <?php endforeach; ?>
     ];
     var currentTime = Date.now();
-    youtubeCodeList.some(function(timeEntry) {
+    embedCodeList.some(function(timeEntry) {
         if(currentTime >= timeEntry[0] && currentTime <= timeEntry[1]) {
             resCode = timeEntry[2];
             return true;
@@ -22,7 +22,7 @@
 }
 
 setInterval(function() {
-    if(getCurrentYoutubeCode() !== startYoutubeCode) {
+    if(getCurrentEmbedCode() !== startEmbedCode) {
         window.location.reload(true);
     }
-}, 5000);
+}, 60000);