使用jwplayer动态rtmp流 [英] Dynamic rtmp streaming with jwplayer

查看:198
本文介绍了使用jwplayer动态rtmp流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JavaScript和php发布动态RTMP流.

I am trying to publish dynamic RTMP stream with javascript and php.

我想从URL获取流名称,并将流发布到我的Web播放器(jwplayer)上 就像xxx.com/watch.php?chanel=music

I want to get stream name from url and publish the stream on my web player (jwplayer) like xxx.com/watch.php?chanel=music

我想使用音乐作为我的流名称,并想与我的jwplayer显示流.假设我的rtmp托管是rtmp://xx.yy.zz.yy:1987/live

I want to use the music as my stream name and want to show the stream with my jwplayer. Suppose my rtmp hosting is rtmp://xx.yy.zz.yy:1987/live

现在,我想从URL获取流名称音乐,并通过jwplayer动态发布完整的流rtmp://xx.yy.zz.yy:1987/live/music.

Now I want to get the stream name music from the url and publish the full stream rtmp://xx.yy.zz.yy:1987/live/music through jwplayer dynamically.

如果有人点击xxx.com/watch.php?chanel=sports,他将能够看到rtmp://xx.yy.zz.yy:1987/live/sports流.

if someone hit xxx.com/watch.php?chanel=sports he will able to see rtmp://xx.yy.zz.yy:1987/live/sports stream.

我写了以下脚本,但是它不起作用

I wrote the following script but its not working

<?php
include ("template/header.html");
?>
<div class="container-fluid">
<script src="stream/jwplayer.js"></script>
<div id="mediaplayer">This div will be replaced by the JW Player</div>
<script>

<script>
var chanel = getQueryVariable("chanel");

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 

}
var host= ("rtmp://216.245.200.114/Live/");
var stream=host.concat(chanel);
jwplayer('mediaplayer').setup({
width: "600",
height: "500",
primary: "flash",
autostart: "true",
repeat: 'always',
sources:[
{   file: stream    }
]
});
</script>
</div>
<?php
include ("template/footer.html");
?>

现在,当我点击 http://www.justlive24.com/watch时. php?chanel = shomoy 不会加载播放器.我是新手,正在尝试找出解决方案.您的简短解释将帮助我理解这一点.

Now when I am hitting the http://www.justlive24.com/watch.php?chanel=shomoy its not loading the player. I am newbie and trying to find out the solution. Your brief explanation will help me to understand this.

推荐答案

您遇到语法错误:
1. http://joxi.ru/nvGdUxjKTJBNH3ESafE
2. http://joxi.ru/yPGdU_3JTJA7Y4XfP7M
还有一些修复方法...

you've syntax error:
1. http://joxi.ru/nvGdUxjKTJBNH3ESafE
2. http://joxi.ru/yPGdU_3JTJA7Y4XfP7M
also some fixes todo...

尝试以下代码: http://pastebin.com/UzhuVpXm

try this code: http://pastebin.com/UzhuVpXm

别忘了在head标签之间附加jquery

don't forget to attach jquery between head tags

这篇关于使用jwplayer动态rtmp流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆