Skip to main content

Topic - Video Playback Events

Description

This topic can be used to monitor video playback events for a specified channel.

Subtypes include:

  • Commercial started
  • Stream went down
  • Stream went up
  • View count update

Note: The stream up/down events tend to be fired significantly faster than what is reported by Helix. Note: the view count reported by this topic is more reflective of the value on the website than API - TMI > Get Viewers

With all undocumented topics, use at your own risk.

Method Definition

By Channel ID (Preferred)

NameTypeDescription
credentialOAuth2CredentialAuth Token (may not necessarily be required)
channelIdStringTarget Channel Id

By Channel Name (Alternative)

NameTypeDescription
credentialOAuth2CredentialAuth Token (may not necessarily be required)
channelNameStringTarget Channel Name

Code-Snippets

Subscribe to topic

By Channel ID

Preferred way to subscribe to the topic; used by first-party clients and more resistant to name weirdness.

twitchClient.getPubSub().listenForVideoPlaybackEvents(credential, "149223493");

By Channel Name

An alternative means to subscribe to the topic, if one does not have the channel ID and does not wish to query it.

twitchClient.getPubSub().listenForVideoPlaybackByNameEvents(credential, "twitch4j");

Listen for Events

// Handle all subtypes
twitchClient.getEventManager().onEvent(VideoPlaybackEvent.class, System.out::println);

// Alternatively, only consider a specific subtype
twitchClient.getEventManager().onEvent(VideoPlaybackEvent.class, e -> {
if (e.getData().getType() == VideoPlaybackData.Type.STREAM_UP) {
System.out.println(e); // Handle Go Live
}
});