如何知道令牌将视频流传输到opentok中的会话的持续时间 [英] How to Know the time duration a token was streaming it's video to a session in opentok

查看:103
本文介绍了如何知道令牌将视频流传输到opentok中的会话的持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已连接,使用令牌订阅了opentok中的会话并流了我的视频.

I connected , subscribed to a session in opentok with a token and streamed my video.

现在我如何获取信息,例如我的视频流了多少时间,以及许多其他对数据分析有用的信息.

Now How do I get informations like How much time did my video streamed, and many other informations which can be useful for data analysis.

 var apiKey = "*****";
 var sessionId = "**************************";
 var token = "************";


            var publisher = TB.initPublisher(apiKey);

            var session = TB.initSession(sessionId);

            session.connect(apiKey, token);
            session.addEventListener("sessionConnected",
                           sessionConnectedHandler);

            session.addEventListener("streamCreated",
                           streamCreatedHandler);

推荐答案

您必须自己跟踪这些数据.例如,创建发布者后,您可以使用当前时间戳Date.now()

You have to keep track of these data yourself. For example, after creating a publisher you can send a post request to your server with the current timestamp Date.now()

当用户断开连接时,您将从会话中的其他人那里收到sessionDisconnected事件,您可以使用当前时间戳记Date.now()将事件发送到服务器以标记结束时间.

When the user disconnects, you will get a sessionDisconnected event from someone else in the session, you can send an event to your server with the current timestamp Date.now() to mark the end time.

要确定已断开连接的流,只需确保在请求中发送用户的connectionId:session.connection.connectionIdstream.connection.connectionId

To identify the streams that have been disconnected, simply make sure you are sending the user's connectionId in your requests: session.connection.connectionId and stream.connection.connectionId

或者,您可以试用OpenTok的 raptor SDK ,它只是一个Java SDK,您可以每次用户连接/断开会话和其他事件时,都可以在Java后端中使用来获取请求.不幸的是,这目前仅适用于Java,OpenTok将很快支持更多SDK.

Alternatively, you can try out OpenTok's raptor SDK, which is simply a Java SDK that you can use in your Java backend to get a request every time a user connects/disconnects to a session and other events. Unfortunately this only works with Java for now, OpenTok will work to support more SDKs soon.

这篇关于如何知道令牌将视频流传输到opentok中的会话的持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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