From 4fd6d147443ff7089009fea91676c784e11f0ea7 Mon Sep 17 00:00:00 2001
From: Cat <carinasadres@gmail.com>
Date: Tue, 24 Jan 2017 11:53:49 +0100
Subject: [PATCH] Embed: support without localStorage

---
 embed/core.js           |  6 +++---
 embed/test.html         | 22 ++++++++++++++++++++++
 embed/wrappers/html5.js |  1 -
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/embed/core.js b/embed/core.js
index 3b7c1fba..64ad322d 100644
--- a/embed/core.js
+++ b/embed/core.js
@@ -303,7 +303,7 @@ MistPlayer.prototype.buildMistControls = function(){
   }
   volume.className = 'volume';
   sound.title = 'Volume';
-  if ('mistVolume' in localStorage) {
+  if (('localStorage' in window) && (localStorage != null) && ('mistVolume' in localStorage)) {
     ele.volume = localStorage['mistVolume'];
     volume.style.height = ele.volume*100+'%';
   }
@@ -452,7 +452,7 @@ MistPlayer.prototype.buildMistControls = function(){
         }
         if (i == 'subtitle')  {
           s.value = 0;
-          if ('mistSubtitle' in localStorage) {
+          if (('localStorage' in window) && (localStorage != null) && ('mistSubtitle' in localStorage)) {
             var option = s.querySelector('[data-lang="'+localStorage['mistSubtitle']+'"]');
             if (option) {
               s.value = option.value;
@@ -1082,7 +1082,7 @@ function mistPlay(streamName,options) {
       catch (e) {
         //show the next player/reload buttons if there is an error in the player build code
         options.target.appendChild(player.element);
-        player.askNextCombo('Error while building player');
+        player.askNextCombo('Error while building player: '+e.stack);
         throw e;
         player.report({
           type: 'init',
diff --git a/embed/test.html b/embed/test.html
index 5e425698..9d862b5e 100644
--- a/embed/test.html
+++ b/embed/test.html
@@ -119,6 +119,28 @@
               //forceSource: 3,
               loop: true,
               //controls: 'stock'
+              streaminfo: {
+                source: [{
+                  type: 'html5/video/mp4',
+                  url: 'http://localhost:8080/bunny.mp4'
+                },{
+                  type: 'html5/application/vnd.apple.mpegurl',
+                  url: 'http://localhost:8080/hls/bunny/index.m3u8'
+                },{
+                  type: 'dash/video/mp4',
+                  url: 'http://localhost:8080/dash/bunny/index.mpd'
+                },{
+                  player_url: '/flashplayer.swf',
+                  type: 'flash/10',
+                  url: 'rtmp://localhost:1935/play/bunny'
+                }],
+                meta: {
+                  tracks: []
+                },
+                height: 404,
+                width: 720,
+                type: 'vod'
+              },
               callback: function(player) {
                 var button = document.createElement('button');
                 button.innerHTML = 'askNextCombo();';
diff --git a/embed/wrappers/html5.js b/embed/wrappers/html5.js
index abb951b9..cbf45a0b 100644
--- a/embed/wrappers/html5.js
+++ b/embed/wrappers/html5.js
@@ -162,7 +162,6 @@ p.prototype.build = function (options) {
       me.addlog('Player event fired: '+e.type);
     },true);
   }
-  
   return cont;
 }
 p.prototype.play = function(){ return this.element.play(); };