txLive模块(直播类)试用分享

发布时间:2020-06-22 11:33:02 作者:罗那尔刘能
来源:网络 阅读:282

本文出自APICloud官方论坛,
感谢论坛版主uoaccw的分享。

txLive 模块封装了腾讯云直播服务
https://docs.apicloud.com/Client-API/Open-SDK/txLive
经过试用,这个模块堪称最简单最快速能使用起来的直播模块。
界面上的按钮,根据自己的需要,可以显示和隐藏。带有各种美颜功能(美白、瘦脸、V形脸)。推流的码率和清晰度可以设置。

使用流程:

  1. 注册腾讯云平台
  2. 进行实名认证
  3. 开通直播服务
  4. 生成推流地址(https://cloud.tencent.com/document/product/454/14551#URL)

代码:
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
        body {
            padding-top: 160px;
            height: 1000px;
        }
        .content {
            margin-top: 350px;
        }
        button {
            margin: 10px;
        }
    </style>
</head>
<body>
    <div class="content">
        <button tapmode type="button" onclick="openPusher()" name="button">openPusher</button>
        <button tapmode type="button" onclick="openPlayer()" name="button">openPlayer</button>
        <button tapmode type="button" onclick="setLiveBtnsVisibility()" name="button">setLiveBtnsVisibility</button>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    apiready = function() {
    };
    function openPusher() {
        var txLive = api.require('txLive');
        txLive.openPusher({
            x: 0,
            y: 50,
            h: 350,
            w: api.winWidth,
            fixedOn: api.frameName,
            fixed: false,
            url: ""   //填写腾讯云平台上生成的推流地址
        });
    }
//播放接口,播放端使用
    function openPlayer() {
        var txLive = api.require('txLive');
        txLive.openPlayer({
            x: 0,
            y: 0,
            url: ""    //填写腾讯云平台上生成的播放地址
        });
    }
    function setLiveBtnsVisibility() {
        var txLive = api.require('txLive');
        txLive.setLiveBtnsVisibility({
            "btnid": "btnLog",
            "show": 0
        });
    }
</script>
</html>
复制代码`

推荐阅读:
  1. Nginx模块概述—干货分享!
  2. 优测优分享 | 这样做测试用例评审更高效

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

腾讯 直播

上一篇:Android的Button监听

下一篇:在window环境下搭建rockmongo

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》