Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit RoomInfo to the client #24

Closed
OlegShklyarov opened this issue Apr 18, 2022 · 6 comments
Closed

Emit RoomInfo to the client #24

OlegShklyarov opened this issue Apr 18, 2022 · 6 comments
Labels
question Further information is requested

Comments

@OlegShklyarov
Copy link

Hello, I am trying to show HLS link in client`s console after connect.

I have added this to connectionWrapper:

	this.connection.getRoomInfo().then(roomInfo => {
		this.log(`HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}`);
		this.emit(`HLS URL: ${roomInfo.stream_url.flv_pull_url.HD1}`);
		})

But client does not receive it, it is visible only only in bash console.

@zerodytrash
Copy link
Owner

The client-side and server-side wrappers used for TikTok-Chat-Reader does not include the getRoomInfo function. But you could easily add them to the wrapper. However, it is currently possible to get the room info by taking it from the connect result. I think the video pull url doesn't change, so you don't need to retrieve the roomInfo again during the connection. Therefore this should be sufficient.

connection.connect('@username').then(state => {

    console.log(state.roomInfo.stream_url.flv_pull_url.HD1);
    
}).catch(err => console.error(err))

image

@zerodytrash zerodytrash added the question Further information is requested label Apr 18, 2022
@zerodytrash
Copy link
Owner

btw it may make more sense to use state.roomInfo.stream_url.hls_pull_url instead flv_pull_url because HLS playback is better supported in web browsers. You can play it with VideoJS or paste the URL here: https://videojs.github.io/videojs-contrib-hls/

@OlegShklyarov
Copy link
Author

Thank you for your help, I will try.

@OlegShklyarov
Copy link
Author

Should I just add it like that?

const { WebcastPushConnection } = require('tiktok-live-connector');
const { EventEmitter } = require('events');

let globalConnectionCount = 0;

/**
 * TikTok LIVE connection wrapper with advanced reconnect functionality and error handling
 */
 
 		connection.connect(uniqueId).then(state => {
        console.log(state.roomInfo.stream_url.flv_pull_url.HD1);
        }).catch(err => console.error(err))

@OlegShklyarov
Copy link
Author

We do not deserve people like you. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants