- Add YouTube-Live-Chat-API as a dependency to your project.
Gradle:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.breadbott:YouTube-Live-Chat-API:1.0.1'
}
maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.breadbott</groupId>
<artifactId>YouTube-Live-Chat-API</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
-
Generate a YouTube API token or an OAuth token at the Google Cloud Console.
-
Make a new YouTubeLive instance. see examples
YouTubeLive.newClient()
.apiKey("API-KEY")
// Or optionally oAuthToken.
//.oAuthToken("OAUTH-TOKEN")
// Use events here.
.onTextMessage((event, client) -> {
String sender = event.getAuthorChannelName();
String message = event.getMessageText();
System.out.println(sender+" > "+message);
})
.buildAndConnect("https://www.youtube.com/watch?v=jfKfPfyJRdk");