溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

txLive模塊(直播類)試用分享

發(fā)布時間:2020-06-22 11:33:02 來源:網(wǎng)絡(luò) 閱讀:295 作者:羅那爾劉能 欄目:開發(fā)技術(shù)

本文出自APICloud官方論壇,
感謝論壇版主uoaccw的分享。

txLive 模塊封裝了騰訊云直播服務(wù)
https://docs.apicloud.com/Client-API/Open-SDK/txLive
經(jīng)過試用,這個模塊堪稱最簡單最快速能使用起來的直播模塊。
界面上的按鈕,根據(jù)自己的需要,可以顯示和隱藏。帶有各種美顏功能(美白、瘦臉、V形臉)。推流的碼率和清晰度可以設(shè)置。

使用流程:

  1. 注冊騰訊云平臺
  2. 進行實名認證
  3. 開通直播服務(wù)
  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>
復(fù)制代碼`

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI