|
我们自己服务器部署的webapi,在线升级版本是最新的,按照例子写了个http的html右键-谷歌可播。https调用方法也是一样的,就换了个端口,但是就播不了,用服务的https的demo也是能播放的,但是自己的https的html就是不行,不是专业的,自己看困扰很久了,希望有人指教,报错在附件图片里,请问是不是https的初始化方法问题。该怎么解决- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>video</title>
- <style>
- html, body {
- position: relative;
- margin: 0;
- padding: 0;
- height: 100%;
- width: 100%;
- }
- </style>
- </head>
- <body>
- <div id="id_video" style="width:100%; height:100%;"></div>
- </body>
- <script type="text/javascript" src="http://121.46.30.137:8081/js/jsw.js"></script>
- <script type="text/javascript">
- var VEDIO_SESSION = null,
- VEDIO_PUID = null,
- VEDIO_CHANNELID = null,
- LOGIN_SERVER = '121.46.30.137',
- LOGIN_PORT = 9701,
- SWINIT_URL = "http://121.46.30.137:8081",
- LOGIN_ACCOUNT = 'test01',
- LOGIN_PWD = '12345678';
- var session = null;
- var hdlg = null;
- function testLogin() {
- if (session) {
- delete session;
- }
- session = new jSW.SWSession({
- server: LOGIN_SERVER,
- port: LOGIN_PORT,
- onopen: function (sess) {
- sess.swLogin({
- user: LOGIN_ACCOUNT,
- password: LOGIN_PWD
- });
- }
- });
- // 注册事件的回调函数
- session.swAddCallBack('login', sessionCallback);
- session.swAddCallBack('logout', sessionCallback);
- }
- function testLogout() {
- if (session) {
- session.swLogout();
- }
- }
- function getPuList() {
- if (session) {
- var pulist = session._arr_pu;
- var pu = pulist["0"];
- // console.log("session",session)
- console.log("pulist", typeof pulist, pulist)
- console.log("pu", typeof pu, pu);
- //todo 默认播放第一个
- var puinfo = pu._info_pu;
- var puId = puinfo.id;
- var videolist = pu._arr_channel;
- var video = videolist[0];
- var videoinfo = video._info_chanel;
- var chanelId = videoinfo.id;
- console.log("puId:", puId);
- console.log("chanelId:", chanelId);
- return {
- puId: puId,
- chanelId: chanelId
- }
- }
- }
- function sessionCallback(sender, event, json) {
- if (json.code == jSW.RcCode.RC_CODE_S_OK) {
- // 成功之后获取播放列表并播放视频
- // 立即执行获取不到session._arr_pu;
- setTimeout(function () {
- var playInfo = getPuList();
- testOpenVideo(playInfo.puId, playInfo.chanelId)
- }, 500)
- }
- }
- function testOpenVideo(puId, chanelId) {
- var chanel = session.swGetPuChanel(puId, chanelId);
- if (chanel) {
- var result = chanel.swOpenEx({
- div: id_video,
- prototype: 'auto', //rtmp > hls
- callback: function (options, response, dlghandle) {
- console.log(response.emms.code + "视频打开成功,可以获取URl了");
- }
- });
- if (result != jSW.RcCode.RC_CODE_S_OK) {
- alert('打开视频失败,机器人不在线! ' );
- }
- } else {
- }
- }
- // 指定dom元素进入全屏模式
- function launchFullscreen(element) {
- if (element.requestFullscreen) {
- element.requestFullscreen();
- } else if (element.mozRequestFullScreen) {
- element.mozRequestFullScreen();
- } else if (element.msRequestFullscreen) {
- element.msRequestFullscreen();
- } else if (element.webkitRequestFullscreen) {
- element.webkitRequestFullScreen();
- }
- }
- function testFullScreen() {
- var szpuid = 'PU_10174';
- var channelindex = 0;
- var chanel = session.swGetPuChanel(szpuid, channelindex);
- var result = chanel.swFullScreen(hdlg);
- if (result != jSW.RcCode.RC_CODE_S_OK) {
- }
- }
- window.onload = function () {
- jSW.swInit({
- url: SWINIT_URL, // bv_nginx.exe服务器地址
- calltype: jSW.CallProtoType.AUTO, // AUTO: IE优先使用OCX, 如果希望IE仍然使用HTTP通信, 请使用jSW.CallProtoType.HTTP
- oninit: testLogin
- });
- }
- window.onbeforeunload = function () {
- jSW.swDeInit();
- }
- </script>
- </html>
copycode- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>video</title>
- <style>
- html, body {
- position: relative;
- margin: 0;
- padding: 0;
- height: 100%;
- width: 100%;
- }
- </style>
- </head>
- <body>
- <div id="id_video" style="width:100%; height:100%;"></div>
- </body>
- <script type="text/javascript" src="http://121.46.30.137:8081/js/jsw.js"></script>
- <script type="text/javascript">
- var VEDIO_SESSION = null,
- VEDIO_PUID = null,
- VEDIO_CHANNELID = null,
- LOGIN_SERVER = '121.46.30.137',
- LOGIN_PORT = 9701,
- SWINIT_URL = "http://121.46.30.137:8081",
- LOGIN_ACCOUNT = 'test01',
- LOGIN_PWD = '12345678';
- var session = null;
- var hdlg = null;
- function testLogin() {
- if (session) {
- delete session;
- }
- session = new jSW.SWSession({
- server: LOGIN_SERVER,
- port: LOGIN_PORT,
- onopen: function (sess) {
- sess.swLogin({
- user: LOGIN_ACCOUNT,
- password: LOGIN_PWD
- });
- }
- });
- // 注册事件的回调函数
- session.swAddCallBack('login', sessionCallback);
- session.swAddCallBack('logout', sessionCallback);
- }
- function testLogout() {
- if (session) {
- session.swLogout();
- }
- }
- function getPuList() {
- if (session) {
- var pulist = session._arr_pu;
- var pu = pulist["0"];
- // console.log("session",session)
- console.log("pulist", typeof pulist, pulist)
- console.log("pu", typeof pu, pu);
- //todo 默认播放第一个
- var puinfo = pu._info_pu;
- var puId = puinfo.id;
- var videolist = pu._arr_channel;
- var video = videolist[0];
- var videoinfo = video._info_chanel;
- var chanelId = videoinfo.id;
- console.log("puId:", puId);
- console.log("chanelId:", chanelId);
- return {
- puId: puId,
- chanelId: chanelId
- }
- }
- }
- function sessionCallback(sender, event, json) {
- if (json.code == jSW.RcCode.RC_CODE_S_OK) {
- // 成功之后获取播放列表并播放视频
- // 立即执行获取不到session._arr_pu;
- setTimeout(function () {
- var playInfo = getPuList();
- testOpenVideo(playInfo.puId, playInfo.chanelId)
- }, 500)
- }
- }
- function testOpenVideo(puId, chanelId) {
- var chanel = session.swGetPuChanel(puId, chanelId);
- if (chanel) {
- var result = chanel.swOpenEx({
- div: id_video,
- prototype: 'auto', //rtmp > hls
- callback: function (options, response, dlghandle) {
- console.log(response.emms.code + "视频打开成功,可以获取URl了");
- }
- });
- if (result != jSW.RcCode.RC_CODE_S_OK) {
- alert('打开视频失败,机器人不在线! ' );
- }
- } else {
- }
- }
- // 指定dom元素进入全屏模式
- function launchFullscreen(element) {
- if (element.requestFullscreen) {
- element.requestFullscreen();
- } else if (element.mozRequestFullScreen) {
- element.mozRequestFullScreen();
- } else if (element.msRequestFullscreen) {
- element.msRequestFullscreen();
- } else if (element.webkitRequestFullscreen) {
- element.webkitRequestFullScreen();
- }
- }
- function testFullScreen() {
- var szpuid = 'PU_10174';
- var channelindex = 0;
- var chanel = session.swGetPuChanel(szpuid, channelindex);
- var result = chanel.swFullScreen(hdlg);
- if (result != jSW.RcCode.RC_CODE_S_OK) {
- }
- }
- window.onload = function () {
- jSW.swInit({
- url: SWINIT_URL, // bv_nginx.exe服务器地址
- calltype: jSW.CallProtoType.AUTO, // AUTO: IE优先使用OCX, 如果希望IE仍然使用HTTP通信, 请使用jSW.CallProtoType.HTTP
- oninit: testLogin
- });
- }
- window.onbeforeunload = function () {
- jSW.swDeInit();
- }
- </script>
- </html>
copycode
|
|