mobile CCTV,mobile surveillance,police body worn cameras

 forgetPW
 registerNow
search
12NextPage
backToList newPost
view: 1907|reply: 15
打印 prevThread nextThread

视频实时预览功能

[copyURL]

1

主题

7

帖子

27

积分

newBie

Rank: 1

积分
27
jumpTo
owner
poston 2020-8-11 09:36 | authorOnly 回帖奖励 |倒序浏览 |阅读模式
目前,需求是将实时视频功能迁移到我司平台,用的demo是


报错信息:


代码是:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>video</title>
</head>
<body>
    <input type="button" value="登录" />
    <input type="button" value="打开视频" />
    <input type="button" id='id_GetUrl_Button' value="获取URL" disabled="disabled" />
    <input id="id_JustUrl_NoPlay" type='checkbox' />只获取Url,不进行播放
    <div id="msg"></div>
    <div id="id_video" style="width:500px; height:400px"></div>
    <div id="id_url_info" style="width:500px; height:200px"></div>
</body>
</html>

<script type="text/javascript" src="http://127.0.0.1:8082/js/jsw.js"></script>
<script type="text/javascript">
    window.onload = function () {
        jSW.swInit({
            url: "http://127.0.0.1:8082", // bv_nginx.exe服务器地址
            calltype: jSW.CallProtoType.AUTO, // AUTO: IE优先使用OCX, 如果希望IE仍然使用HTTP通信, 请使用jSW.CallProtoType.HTTP
        });
    }
    window.onbeforeunload = function () {
        jSW.swDeInit();
    }

    var session = null;
    function testLogin() {
        if (session) { delete session; }
        session = new jSW.SWSession({
            server: '127.0.0.1', // 如果是jSW.CallProtoType.OCX方式,这里需要填写具体的IP
            port: 9701,
            onopen: function (sess) {
                    sess.swLogin({
                        user: 'admin',
                        password: '123456'
                    });
                }
        });

        // 注册事件的回调函数
        session.swAddCallBack('login', sessionCallback);
        session.swAddCallBack('logout', sessionCallback);
    }

    function testLogout() {
        if (session) {
            session.swLogout();
        }
    }

    function sessionCallback(sender, event, json) {
        var info = '';
        if ('login' == event) {
            info += '登录';
        } else if ('logout' == event) {
            info += '退出';
        }

        if (json.code == jSW.RcCode.RC_CODE_S_OK) {
            info += '成功';
        } else {
            info += '失败, error code: ' + json.code;
        }

        document.getElementById('msg').innerHTML = info + '<br/><textarea rows="18" cols="100" readonly="readonly"> ' + JSON.stringify(json, null, 4) + '</textarea>';
    }

    function testOpenVideo() {
        var chanel = session.swGetPuChanel('27279928', 0);
        var strVideoDivId = document.getElementById('id_JustUrl_NoPlay').checked == true ? null : 'id_video';
        if (chanel) {
            var result = chanel.swOpenEx({
                div: strVideoDivId,
                prototype: 'auto', //rtmp > hls
                callback: function (options, response) {
                    alert(response.emms.code + "视频打开成功,可以获取URl了");
                    document.getElementById('id_GetUrl_Button').disabled = 'false';
                }
            });

            if (result != jSW.RcCode.RC_CODE_S_OK) {
                alert('打开视频失败: ' + result);
                document.getElementById('id_GetUrl_Button').disabled = 'true';
            }
        } else {
            alert('没有该设备通道');
        }
    }

    function testGetUrlVideo(){
        var chanel = session.swGetPuChanel('PU_55AA0000', 0);
        var url = chanel.swGetUrl();
         document.getElementById('id_url_info').innerHTML = JSON.stringify(url, null, 4);
    }
</script>


请问是什么原因,哪里出问题了?




reply

使用道具 report

60

主题

1410

帖子

5785

积分

Moderator

Rank: 7Rank: 7Rank: 7

积分
5785
sofa
poston 2020-8-11 09:39 | authorOnly
是用chrome的吧?
reply agree Against

使用道具 report

1

主题

7

帖子

27

积分

newBie

Rank: 1

积分
27
bench
 Owner| poston 2020-8-11 09:42 | authorOnly

是用chrome的
reply agree Against

使用道具 report

3

主题

59

帖子

367

积分

midMem

Rank: 3Rank: 3

积分
367
ground
poston 2020-8-11 09:44 | authorOnly
没看到报错信息,只看到代码了,报错信息没上传么
reply agree Against

使用道具 report

11

主题

199

帖子

921

积分

advMem

Rank: 4

积分
921
5#
poston 2020-8-11 09:45 | authorOnly
请注意格式PU_ID
reply agree Against

使用道具 report

1

主题

383

帖子

1466

积分

vipMem

Rank: 6Rank: 6

积分
1466
6#
poston 2020-8-11 09:49 | authorOnly
是不是input控件里没有加入点击触发函数的语句

本帖子中包含更多资源

pls login 才可以下载或查看,没有帐号?registerNow

x
reply agree Against

使用道具 report

1

主题

7

帖子

27

积分

newBie

Rank: 1

积分
27
7#
 Owner| poston 2020-8-11 09:49 | authorOnly
好的,可以了,
建议文档里     var chanel = session.swGetPuChanel('PU_55AA0000', 0);写好格式说明
reply agree Against

使用道具 report

1

主题

7

帖子

27

积分

newBie

Rank: 1

积分
27
8#
 Owner| poston 2020-8-11 09:57 | authorOnly
还有一个问题,如果我需要四个视频窗口,用你们示例demo只有一个窗口,多个窗口是需要我们自己开发吗
reply agree Against

使用道具 report

1

主题

383

帖子

1466

积分

vipMem

Rank: 6Rank: 6

积分
1466
9#
poston 2020-8-11 10:08 | authorOnly
huangchaowei post on2020-8-11 09:57
还有一个问题,如果我需要四个视频窗口,用你们示例demo只有一个窗口,多个窗口是需要我们自己开发吗

是的 需要您那边开发一下
reply agree Against

使用道具 report

0

主题

22

帖子

162

积分

member

Rank: 2

积分
162
10#
poston 2020-8-11 10:11 | authorOnly
huangchaowei post on2020-8-11 09:49
好的,可以了,
建议文档里     var chanel = session.swGetPuChanel('PU_55AA0000', 0);写好格式说明

已补充格式说明
reply agree Against

使用道具 report

creditRule

QQ|wireless surveillance

GMT+8, 2024-4-19 12:36 , Processed in 0.144536 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

QuickReply backToTop BackToList