@@ -371,16 +371,28 @@ namespace Mist{
371371 if (mistPath.size ()){fullURL = mistPath;}
372372 std::string uAgent = req.GetHeader (" User-Agent" );
373373
374- std::string forceType = " " ;
375- if (req.GetVar (" forcetype" ).size ()){
376- forceType = " ,forceType:\" " + req.GetVar (" forcetype" ) + " \" " ;
374+ JSON::Value opts;
375+ opts[" host" ] = fullURL.getUrl ();
376+ opts[" urlappend" ] = req.allVars ();
377+ opts[" fillSpace" ] = true ;
378+
379+ // These parameters are checked if they are passed at all (unset is also accepted)
380+ // This check works by comparing the global unset empty string pointer against the variables string pointer:
381+ // If they match, it was not passed at all. If they mismatch, it was passed either with or without a value.
382+ if (req.GetVar (" dev" ).data () != req.GetVar (" " ).data ()) { opts[" skin" ] = " dev" ; }
383+ if (req.GetVar (" muted" ).data () != req.GetVar (" " ).data ()) { opts[" muted" ] = true ; }
384+ if (req.GetVar (" nounix" ).data () != req.GetVar (" " ).data ()) { opts[" useDateTime" ] = false ; }
385+ if (req.GetVar (" nocatchup" ).data () != req.GetVar (" " ).data ()) { opts[" liveCatchup" ] = false ; }
386+
387+ // These parameters must have a non-empty value set to take effect
388+ if (req.GetVar (" forceType" ).size ()) { opts[" forceType" ] = req.GetVar (" forceType" ); }
389+ if (req.GetVar (" forcetype" ).size ()) { opts[" forceType" ] = req.GetVar (" forcetype" ); }
390+ if (req.GetVar (" forcePlayer" ).size ()) { opts[" forcePlayer" ] = req.GetVar (" forcePlayer" ); }
391+ if (req.GetVar (" forceplayer" ).size ()) { opts[" forcePlayer" ] = req.GetVar (" forceplayer" ); }
392+ if (req.GetVar (" autoplay" ).size ()) {
393+ if ((req.GetVar (" autoplay" ) == " false" ) || (req.GetVar (" autoplay" ) == " 0" )) { opts[" autoplay" ] = false ; }
377394 }
378395
379- std::string devSkin = " " ;
380- if (req.GetVar (" dev" ).size ()){devSkin = " ,skin:\" dev\" " ;}
381- devSkin += " ,urlappend:\" " + req.allVars () + " \" " ;
382- H.SetVar (" stream" , streamName);
383-
384396 std::string seekTo = " " ;
385397 if (req.GetVar (" t" ).size ()){
386398 uint64_t autoSeekTime = 0 ;
@@ -427,9 +439,9 @@ namespace Mist{
427439 " \" type=\" application/vnd.apple.mpegurl\" ><source src=\" " + mp4Url + " \" type=\" video/mp4\" ><a href=\" " +
428440 hlsUrl + " \" >Click here to play the video [Apple]</a><br><a href=\" " + mp4Url +
429441 " \" >Click here to play the video [MP4]</a></video></noscript><script "
430- " src=\" player.js\" ></script><script>var mv ={reference:false}; mistPlay(' " +
431- streamName + " ',{host:' " + fullURL. getUrl () + " ', target: document.getElementById('" + streamName +
432- " '), MistVideoObject:mv " + forceType + devSkin + " } );" + seekTo + " </script></div></body></html>" );
442+ " src=\" player.js\" ></script><script>var mv={reference:false}; var opts= " +
443+ opts. toString () + " ;opts. target= document.getElementById('" + streamName +
444+ " ');opts. MistVideoObject = mv;mistPlay(' " + streamName + " ',opts );" + seekTo + " </script></div></body></html>" );
433445 H.SendResponse (" 200" , " OK" , myConn);
434446 responded = true ;
435447 H.Clean ();
0 commit comments