当我从HLS文件的URL传递数据时,播放器停止工作,就好像它不存在一样:
<?php
$url = $_GET['player'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Player HLS</title>
<script src="https://jwpsrv.com/library/FfMxTl3oEeSEiiIACxmInQ.js"></script>
</head>
<body>
<div id="aRzklaXf">Loading the player...</div>
<script type="text/javascript">
//var urlplay = "https://c6d34z8w3zavhqt3.ezcdn483.net:8443/hls/dcgmsy35q.m3u8?s=qm3aTTYK9EvvG8aHlbOGMg&e=1614565195";
var urlplay = "<?php echo $url; ?>";
var playerInstance = jwplayer("aRzklaXf");
playerInstance.setup({
//"file": "https://c6d34z8w3zavhqt3.ezcdn483.net:8443/hls/dcgmsy35q.m3u8?s=qm3aTTYK9EvvG8aHlbOGMg&e=1614565195",
"file": urlplay,
"height":"560",
"width":"50%",
stretching: "bestfit",
"image": "#",
"mediaid": "player",
"mute": false,
"autostart": false,
"cast": {
"appid": "player",
"logo": "https://i.ibb.co/Tgk2YrC/Logo.png",
},
});
</script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</body>
但是如果我把这个var urlplay = "<?php echo $ulr; ?>";
换成这个var urlplay = "https://c6d34z8w3zavhqt3.ezcdn483.net:8443/hls/dcgmsy35q.m3u8?s=qm3aTTYK9EvvG8aHlbOGMg&e=1614565195";
它就可以了
为什么它不工作?因为它可以直接添加路由,而且不需要手动使用PHP中使用的方法。
我认为罪魁祸首是一个小错字$url
vs$ulr
($url = $_GET['player'];
vs .var urlplay = "<?php echo $ulr; ?>";
)
:)
取决于$_GET['player']得到什么。你需要看看$_GET['player']是什么,然后像这样填写url。
<script type="text/javascript">
//var urlplay = "https://c6d34z8w3zavhqt3.ezcdn483.net:8443/hls/dcgmsy35q.m3u8?s=qm3aTTYK9EvvG8aHlbOGMg&e=1614565195";
var urlplay = "https://c6d34z8w3zavhqt3.ezcdn483.net:8443/hls/<?php echo $ulr; ?>";
var playerInstance = jwplayer("aRzklaXf");
playerInstance.setup({
//"file": "https://c6d34z8w3zavhqt3.ezcdn483.net:8443/hls/dcgmsy35q.m3u8?s=qm3aTTYK9EvvG8aHlbOGMg&e=1614565195",
"file": urlplay,
"height":"560",
"width":"50%",
stretching: "bestfit",
"image": "#",
"mediaid": "player",
"mute": false,
"autostart": false,
"cast": {
"appid": "player",
"logo": "https://i.ibb.co/Tgk2YrC/Logo.png",
},
});
</script>