
Unexpected error
Hello,
I'm struggling with some authorisation code to protect my live streams.
I have a flussonic stream server with token authentication.
All is fine when i use the <iframe> option but that player isn't my first choice,i just want to use jwplayer.
I have follwing code from the stream server with auth token...
<?php
$streamname = "Stream-7";
$flussonic = "https://xxxx.xxx.sc";
$password = "5678";
$session_lifetime = 3; // in hours
$query = http_build_query(array(
"password" => $password,
"name" => $streamname,
"ip" => $_SERVER["REMOTE_ADDR"],
"salt" => bin2hex(openssl_random_pseudo_bytes(16)),
"starttime" => time(),
"endtime" => time() + $session_lifetime*3600));
$token = file_get_contents("$flussonic/securetoken/sign?$query");
$embed = "$flussonic/$streamname/index.m3u8?token=$token";
?>
And the html i use is...
<body>
<div id="player">Loading the player...</div>
<script>
// Setup the player
const player = jwplayer('player').setup({
file: '<?= $embed?>'
});
// Listen to an event
player.on('pause', (event) => {
alert('Why did my user pause their video instead of watching it?');
});
// Call the API
const bumpIt = () => {
const vol = player.getVolume();
player.setVolume(vol + 10);
}
bumpIt();
</script>
</body>
When i do it this way i get error Uncaught SyntaxError: Invalid or unexpected token
<a href="https://gyazo.com/4db1a7d87ebb3dcd15440e62d95ba9b3"><img src="https://i.gyazo.com/4db1a7d87ebb3dcd15440e62d95ba9b3.png" alt="https://gyazo.com/4db1a7d87ebb3dcd15440e62d95ba9b3" width="1554"/></a>
When i use the player without the token scrip the player runs perfect!!
<body>
<div id="player">Loading the player...</div>
<script>
// Setup the player
const player = jwplayer('player').setup({
file: 'https://xxxx.xxx.sc/Stream-7/index.m3u8'
});
// Listen to an event
player.on('pause', (event) => {
alert('Why did my user pause their video instead of watching it?');
});
// Call the API
const bumpIt = () => {
const vol = player.getVolume();
player.setVolume(vol + 10);
}
bumpIt();
</script>
</body>
When i use the standard iframe embed option from the streamserver i have excactly the same streamurl with the token
<a href="https://gyazo.com/c7e28c3ee13b831c2619132a5999c0d1"><img src="https://i.gyazo.com/c7e28c3ee13b831c2619132a5999c0d1.png" alt="https://gyazo.com/c7e28c3ee13b831c2619132a5999c0d1" width="1080"/></a>
Does anyone know what the problem here is i searching already a week to find the solution!!
Thanks in advance