Commit 4e6c9176 authored by Simon Kirsten's avatar Simon Kirsten
Browse files

Major rework and restructure

parent eac36ee6
Pipeline #23802 failed with stages
in 42 seconds
stream-tv-server*
binaries/
.vscode
version
\ No newline at end of file
/binaries/
/.vscode
/version
/stream-server*
*-packr.go
\ No newline at end of file
# This is the CI file for the stream-tv-server
# This is the CI file for the stream-server
server:
stage: build
......@@ -7,19 +7,20 @@ server:
before_script:
- go mod download
# TWITCH_CLIENT_ID is supplied via the GitLab CI/CD environment variables. This way only project owners can see the private key
- export LDFLAGS="-s -X main.twitchClientID=$TWITCH_CLIENT_ID -X main.version=$(cat version)"
- export LDFLAGS="-s -X stream-server/internal/server.defaultTwitchClientID=$TWITCH_CLIENT_ID -X stream-server/internal/server.Version=$(cat version)"
- cd internal/server/ && packr2 && cd ../../
script:
- env GOOS=darwin GOARCH=386 go build -ldflags "$LDFLAGS" -o binaries/darwin-x86/stream-tv-server ./cmd/stream-tv-server
- env GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o binaries/darwin-x86_64/stream-tv-server ./cmd/stream-tv-server
- env GOOS=darwin GOARCH=386 go build -ldflags "$LDFLAGS" -o binaries/darwin-x86/stream-server ./cmd/stream-server
- env GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o binaries/darwin-x86_64/stream-server ./cmd/stream-server
- env GOOS=linux GOARCH=386 go build -ldflags "$LDFLAGS" -o binaries/linux-x86/stream-tv-server ./cmd/stream-tv-server
- env GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o binaries/linux-x86_64/stream-tv-server ./cmd/stream-tv-server
- env GOOS=linux GOARCH=arm go build -ldflags "$LDFLAGS" -o binaries/linux-arm/stream-tv-server ./cmd/stream-tv-server
- env GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o binaries/linux-arm64/stream-tv-server ./cmd/stream-tv-server
- env GOOS=linux GOARCH=386 go build -ldflags "$LDFLAGS" -o binaries/linux-x86/stream-server ./cmd/stream-server
- env GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o binaries/linux-x86_64/stream-server ./cmd/stream-server
- env GOOS=linux GOARCH=arm go build -ldflags "$LDFLAGS" -o binaries/linux-arm/stream-server ./cmd/stream-server
- env GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o binaries/linux-arm64/stream-server ./cmd/stream-server
- env GOOS=windows GOARCH=386 go build -ldflags "$LDFLAGS" -o binaries/windows-x86/stream-tv-server.exe ./cmd/stream-tv-server
- env GOOS=windows GOARCH=amd64 go build -ldflags "$LDFLAGS" -o binaries/windows-x86_64/stream-tv-server.exe ./cmd/stream-tv-server
- env GOOS=windows GOARCH=386 go build -ldflags "$LDFLAGS" -o binaries/windows-x86/stream-server.exe ./cmd/stream-server
- env GOOS=windows GOARCH=amd64 go build -ldflags "$LDFLAGS" -o binaries/windows-x86_64/stream-server.exe ./cmd/stream-server
artifacts:
paths: # pass binaries directory to deploy stage
......
# Contributing
https://simons-nzse-2.h-da.io/stream-tv/about/contributing/
\ No newline at end of file
#### https://stream-server.h-da.io/about/contributing/
# Stream TV Project
# Stream Server
https://simons-nzse-2.h-da.io/stream-tv/
\ No newline at end of file
#### https://stream-server.h-da.io/
\ No newline at end of file
......@@ -3,38 +3,15 @@ package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/urfave/cli"
"stream-tv/internal/api"
"stream-tv/internal/util"
"stream-tv/internal/website"
"stream-tv/pkg/twitch"
"stream-server/internal/server"
"stream-server/internal/util"
)
const (
docURL = "https://simons-nzse-2.h-da.io/stream-tv/server/"
)
var (
// version will automatically be set by the CI pipeline.
version = "dev"
// twitchClientID will automatically be set by the CI pipeline.
twitchClientID = ""
)
func init() {
// If you want to use your own twitch client id set the TWITCH_CLIENT_ID environment variable.
if clientID := os.Getenv("TWITCH_CLIENT_ID"); clientID != "" {
twitch.ClientID = clientID
} else {
twitch.ClientID = twitchClientID
}
}
const docURL = "https://stream-server.h-da.io"
func main() {
app := cli.NewApp()
......@@ -44,10 +21,10 @@ func main() {
var flagLocal bool
var flagHelp bool
app.Usage = "Stream TV Server " + docURL
app.Usage = docURL
app.HideHelp = true
app.Version = version
app.Version = server.Version
app.Flags = []cli.Flag{
cli.IntFlag{
......@@ -109,16 +86,10 @@ func main() {
}
}
fmt.Printf("Read the documentation at %squickstart/ to get started.\n", docURL)
fmt.Printf("Read the quickstart at %s/quickstart to get started.\n", docURL)
fmt.Printf("Stop with Ctrl-C or close this terminal.\n")
mux := http.NewServeMux() // new router
mux.Handle("/", website.Handler())
mux.Handle("/twitch/", api.TwitchHandler())
mux.Handle("/tv/", api.TVHandler())
return http.ListenAndServe(listenAddr, mux)
return server.ListenAndServe(listenAddr)
}
err := app.Run(os.Args)
......
!!! note
To upgrade the Stream Server to the latest version just replace the executable with the newest from [Downloads](../download-and-run.md#download). There are no dependencies.
<!-- Insert CHANGELOG.md from the root -->
--8<-- "CHANGELOG.md"
......@@ -19,21 +19,21 @@ CI pipeline: `.gitlab-ci-docs.yml`
## Server
> `go.mod`, `go.sum`, `cmd/`, `internal/`, `pkg/`
The Stream TV Server is written in [Go](https://golang.org). It uses [Go Modules](https://github.com/golang/go/wiki/Modules).
The Stream Server is written in [Go](https://golang.org). It uses [Go Modules](https://github.com/golang/go/wiki/Modules).
`go.mod` and `go.sum` are for the module system to ensure [Reproducible builds](https://reproducible-builds.org/).
The `cmd/` directory contains only the `stream-tv-server` command. It sets up the HTTP server and forwards requests to the respective `website`, `twitch` and `tv` handlers in `internal/`.
The `cmd/` directory contains only the `stream-server` command. The code of the server is in `internal/server` and the static files for the playback website in `internal/static`.
`pkg/` contains project independent code to access the Twitch API. This separation is done in accordance to the [Standard Go Project Layout](https://github.com/golang-standards/project-layout).
Local development (requires go 1.12 and a twitch client id):
Local development (requires go 1.12 and a Twitch client id):
``` bash tab="bash" linenums="1"
env TWITCH_CLIENT_ID="your client id here" go run ./cmd/stream-tv-server/main.go
env TWITCH_CLIENT_ID="your client id here" go run ./cmd/stream-server
```
``` PowerShell tab="PowerShell" linenums="1"
$env:TWITCH_CLIENT_ID="your client id here"
go run .\cmd\stream-tv-server\main.go
go run .\cmd\stream-server
```
CI pipeline: `.gitlab-ci-server.yml`
......
# `StreamTV.java`
# Android Integration
This is a very simple helper to call the Stream TV server. See the [reference](reference.md) for examples (select the `StreamTV.java` example tab).
This is a very simple helper to call the Stream Server. See the [reference](reference.md) for examples (select the `StreamServerClient.java` example tab).
!!! note
The abstraction level is about on the same as the `HttpRequest.java` of the original TV-Server. The students still have to implement AsyncTask and all the other stuff.
Also the package definition in the first line needs to be updated.
[Download](../assets/StreamTV.java) · [View in GitLab](#todo)
## `StreamServerClient.java`
<!-- Insert StreamTV.java -->
[Download](../assets/StreamServerClient.java) · [View in GitLab](https://code.fbi.h-da.de/stream-server/stream-server/blob/master/docs/assets/StreamServerClient.java)
<!-- Insert StreamServerClient.java -->
``` java linenums="1"
--8<-- "docs/assets/StreamTV.java"
--8<-- "docs/assets/StreamServerClient.java"
```
\ No newline at end of file
package de.simonkirsten.streamtvexampleapp;
package de.simonkirsten.streamserverclient;
import android.net.Uri;
import android.support.annotation.NonNull;
......@@ -19,27 +19,27 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class StreamTV {
public class StreamServerClient {
private Uri baseUri;
/**
* Creates a new instance of StreamTV.
* Creates a new instance of StreamServerClient.
* The instance is very lightweight so it is okay to create a new instance for each request.
*
* @param ipAddressWithPort The IP address with port e.g. "10.0.2.2:8080"
*/
public StreamTV(String ipAddressWithPort) {
public StreamServerClient(String ipAddressWithPort) {
baseUri = Uri.parse("http://" + ipAddressWithPort);
}
/**
* Creates a new instance of StreamTV.
* Creates a new instance of StreamServerClient.
* The instance is very lightweight so it is okay to create a new instance for each request.
*
* @param ipAddress The IP address e.g. "10.0.2.2"
* @param port The port e.g. 8080
*/
public StreamTV(String ipAddress, int port) {
public StreamServerClient(String ipAddress, int port) {
baseUri = Uri.parse("http://" + ipAddress + ":" + port);
}
......@@ -92,8 +92,8 @@ public class StreamTV {
}
/**
* Updates and returns the new state of the TV.
* Reference at <a href="https://simons-nzse-2.h-da.io/stream-tv/server/reference/#tvstate">https://simons-nzse-2.h-da.io/stream-tv/server/reference/#tvstate</a>
* Updates and returns the new state of the display.
* Reference at <a href="https://stream-server.h-da.io/reference#display">https://stream-server.h-da.io/reference#display</a>
*
* @param large_channel Sets the channel name of the large screen.
* This screen is the always visible main screen.
......@@ -118,7 +118,7 @@ public class StreamTV {
* @param show_chat Sets whether the chat should be shown or not.
* Set to null to keep the old value.
*/
public JSONObject tvState(@Nullable String large_channel, @Nullable String small_channel, @Nullable Float volume, @Nullable Float small_scale, @Nullable Boolean show_chat) throws IOException, JSONException {
public JSONObject display(@Nullable String large_channel, @Nullable String small_channel, @Nullable Float volume, @Nullable Float small_scale, @Nullable Boolean show_chat) throws IOException, JSONException {
Map<String, String> params = new HashMap<>();
if (large_channel != null) {
params.put("large_channel", large_channel);
......@@ -140,38 +140,38 @@ public class StreamTV {
params.put("show_chat", show_chat.toString());
}
String content = doRequest("/tv/state", params);
String content = doRequest("/display", params);
return new JSONObject(content);
}
/**
* Gets the most popular games on Twitch right now.
* Reference at <a href="https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchgamestop">https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchgamestop</a>
* Reference at <a href="https://stream-server.h-da.io/reference#twitchgettopgames">https://stream-server.h-da.io/reference#twitchgamestop</a>
*/
public List<JSONObject> twitchGamesTop() throws IOException, JSONException {
String content = doRequest("/twitch/games/top", null);
public List<JSONObject> twitchGetTopGames() throws IOException, JSONException {
String content = doRequest("/twitch/getTopGames", null);
return jsonArrayToJsonObjectList(new JSONArray(content));
}
/**
* Searches games by query.
* Reference at <a href="https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchgamessearch">https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchgamessearch</a>
* Reference at <a href="https://stream-server.h-da.io/reference#twitchsearchgames">https://stream-server.h-da.io/reference#twitchsearchgames</a>
*
* @param query What should be searched.
*/
public List<JSONObject> twitchGamesSearch(@NonNull String query) throws IOException, JSONException {
public List<JSONObject> twitchSearchGames(@NonNull String query) throws IOException, JSONException {
Map<String, String> params = new HashMap<>();
params.put("query", query);
String content = doRequest("/twitch/games/search", params);
String content = doRequest("/twitch/searchGames", params);
return jsonArrayToJsonObjectList(new JSONArray(content));
}
/**
* Gets the most popular streams on Twitch right now. Optionally filter by channels, game and language.
* Reference at <a href="https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchstreamstop">https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchstreamstop</a>
* Reference at <a href="https://stream-server.h-da.io/reference#twitchgettopstreams">https://stream-server.h-da.io/reference#twitchgettopstreams</a>
*
* @param channels Specify up to 100 channels separated by `,` that the search should be limited to.
* See the examples in the reference why that would be useful.
......@@ -180,7 +180,7 @@ public class StreamTV {
*
* @param language Specify a language that the search should be limited to.
*/
public List<JSONObject> twitchStreamsTop(@Nullable String[] channels, @Nullable String game, @Nullable String language) throws IOException, JSONException {
public List<JSONObject> twitchGetTopStreams(@Nullable String[] channels, @Nullable String game, @Nullable String language) throws IOException, JSONException {
Map<String, String> params = new HashMap<>();
if (channels != null) {
params.put("channels", TextUtils.join(",", channels));
......@@ -194,17 +194,17 @@ public class StreamTV {
params.put("language", language);
}
String content = doRequest("/twitch/streams/top", params);
String content = doRequest("/twitch/getTopStreams", params);
return jsonArrayToJsonObjectList(new JSONArray(content));
}
/**
* Gets the featured games on Twitch's homepage.
* Reference at <a href="https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchstreamsfeatured">https://simons-nzse-2.h-da.io/stream-tv/server/reference/#twitchstreamsfeatured</a>
* Reference at <a href="https://stream-server.h-da.io/reference#twitchgetfeaturedstreams">https://stream-server.h-da.io/reference#twitchgetfeaturedstreams</a>
*/
public List<JSONObject> twitchStreamsFeatured() throws IOException, JSONException {
String content = doRequest("/twitch/streams/featured", null);
public List<JSONObject> twitchGetFeaturedStreams() throws IOException, JSONException {
String content = doRequest("/twitch/getFeaturedStreams", null);
return jsonArrayToJsonObjectList(new JSONArray(content));
}
......
!!! note
To upgrade the Stream TV Server to the latest version just replace the executable with the newest from [Downloads](/server/#download). There are no dependencies.
<!-- Insert CHANGELOG.md from the root -->
--8<-- "CHANGELOG.md"
# Stream TV Server
# Download and Run
## Download
......@@ -8,14 +8,14 @@ Version `
OS | CPU Platform | Download
--------------- | ------------- | ----------------------------------------------------------------------
Windows | 64 bit | [stream-tv-server.exe](../binaries/windows-x86_64/stream-tv-server.exe)
&nbsp; | 32 bit | [stream-tv-server.exe](../binaries/windows-x86/stream-tv-server.exe)
Linux | 64 bit | [stream-tv-server](../binaries/linux-x86_64/stream-tv-server)
&nbsp; | 32 bit | [stream-tv-server](../binaries/linux-x86/stream-tv-server)
&nbsp; | ARM64 | [stream-tv-server](../binaries/linux-arm64/stream-tv-server)
&nbsp; | ARM32 | [stream-tv-server](../binaries/linux-arm/stream-tv-server)
Darwin (macOS) | 64 bit | [stream-tv-server](../binaries/darwin-x86_64/stream-tv-server)
&nbsp; | 32 bit | [stream-tv-server](../binaries/darwin-x86/stream-tv-server)
Windows | 64 bit | [stream-server.exe](../binaries/windows-x86_64/stream-server.exe)
&nbsp; | 32 bit | [stream-server.exe](../binaries/windows-x86/stream-server.exe)
Linux | 64 bit | [stream-server](../binaries/linux-x86_64/stream-server)
&nbsp; | 32 bit | [stream-server](../binaries/linux-x86/stream-server)
&nbsp; | ARM64 | [stream-server](../binaries/linux-arm64/stream-server)
&nbsp; | ARM32 | [stream-server](../binaries/linux-arm/stream-server)
Darwin (macOS) | 64 bit | [stream-server](../binaries/darwin-x86_64/stream-server)
&nbsp; | 32 bit | [stream-server](../binaries/darwin-x86/stream-server)
??? expert info
If you do not wish to use a precompiled executable you can [compile it yourself](../about/contributing/#server).
......@@ -23,24 +23,24 @@ Darwin (macOS) | 64 bit | [stream-tv-server](../binaries/darwin-x86_64/stream-t
## Run
### Windows
1. Just double-click the exe or run it in a cmd or PowerShell `.\stream-tv-server.exe`.
1. Just double-click the exe or run it in a cmd or PowerShell `.\stream-server.exe`.
2. *Optional:* Provide [command-line options](options.md).
!!! warning
If you get [this](../assets/windows-protected-your-pc.png) *"Windows protected your PC"* warning press <kbd>More info</kbd> and <kbd>Run anyway</kbd>.
### Linux
1. Assign the file execute permission in a terminal: `chmod +x stream-tv-server`.
2. Run it from the terminal `./stream-tv-server`.
1. Assign the file execute permission in a terminal: `chmod +x stream-server`.
2. Run it from the terminal `./stream-server`.
3. *Optional:* Provide [command-line options](options.md).
### Darwin (macOS) <small>in the Terminal</small>
1. Assign the file execute permission in a terminal: `chmod +x stream-tv-server`.
2. Run it from the terminal `./stream-tv-server`.
1. Assign the file execute permission in a terminal: `chmod +x stream-server`.
2. Run it from the terminal `./stream-server`.
3. *Optional:* Provide [command-line options](options.md).
### Darwin (macOS) <small>from the GUI</small>
1. Assign the file execute permission in a terminal: `chmod +x stream-tv-server`.
1. Assign the file execute permission in a terminal: `chmod +x stream-server`.
!!! important
This is important as otherwise macOS will try to edit the file in TextEdit when you open it.
......@@ -54,15 +54,13 @@ Darwin (macOS) | 64 bit | [stream-tv-server](../binaries/darwin-x86_64/stream-t
## Common Errors
- <small>`listen tcp 0.0.0.0:80: bind: permission denied`</small>
* listen tcp 0.0.0.0:80: bind: permission denied
The port range below 1024 is restricted on \*nix systems to superusers ([more info](https://unix.stackexchange.com/a/16568)).
Either run as superuser `sudo ./stream-tv-server -p 80` or change the port.
> The port range below 1024 is restricted on \*nix systems to superusers ([more info](https://unix.stackexchange.com/a/16568)).
> Either run as superuser `sudo ./stream-server -p 80` or change the port.
- <small>`listen tcp 0.0.0.0:8080: bind: address already in use`</small>
* listen tcp 0.0.0.0:8080: bind: address already in use
<small>`listen tcp 0.0.0.0:8080: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.`</small>
Something is already using the port. This could be another Stream TV Server instance or some other application (like a webserver).
Close / disable the other service or change the port via the [command-line options](options.md).
> Something is already using the port. This could be another Stream Server instance or some other application (like a webserver).
> Close / disable the other service or change the port via the [command-line options](options.md).
# Stream TV Project
# Stream Server
Stream TV is a project developed at Darmstadt University of Applied Sciences [h-da.de](https://h-da.de) for the User-Centric Software Development hands-on training. In the course the students develop an Android app that remote controls the Stream TV Server.
Stream Server is a project developed at Darmstadt University of Applied Sciences [h-da.de](https://h-da.de) for the User-Centric Software Development hands-on training. In the course the students develop an Android app that remote controls the Stream Server.
This server displays streams of the popular [Twitch.tv](https://twitch.tv) livestream platform on the student's target device (laptop, desktop, tv, smart device, etc.).
The apps can request the server via a simple HTTP API to query the Twitch API for content and to change the state of the display (e.g. control playback).
......@@ -17,14 +17,11 @@ The goal was to
## Documentation layout
- **Project**
_What you are reading right now_ and [Changelog](changelog.md).
- **Server**
[Download and Run](server/index.md), [Options](server/options.md), [Quickstart](server/quickstart.md), [Reference](server/reference.md) and [Java integration](server/streamtv-java.md).
- **Stream Server**
_What you are reading right now_, [Download and Run](download-and-run.md), [Options](options.md), [Quickstart](quickstart.md), [Reference](reference.md) and [Android Integration](android-integration.md).
- **About**
[Contributing info (code layout, build and deploy instructions etc.)](about/contributing.md), [Author's notes](about/authors-notes.md), [Previous considerations](about/previous-considerations.md) and [License](about/license.md).
[Changelog](about/changelog.md), [Contributing info (code layout, build and deploy instructions etc.)](about/contributing.md), [Author's Notes](about/authors-notes.md), [Previous Considerations](about/previous-considerations.md) and [License](about/license.md).
!!! info
......
......@@ -7,17 +7,17 @@
This is totally fine for most users. You can skip this page.
```bash
$ ./stream-tv-server --help
$ ./stream-server --help
```
```
NAME:
stream-tv-server.exe - Stream TV Server https://simons-nzse-2.h-da.io/stream-tv/server/
stream-server - https://stream-server.h-da.io
USAGE:
stream-tv-server.exe [global options] [arguments...]
stream-server [global options] [arguments...]
VERSION:
v0.9.1
v0.9.9
GLOBAL OPTIONS:
--port value, -p value http port to listen on (default: 8080)
......@@ -27,7 +27,7 @@ GLOBAL OPTIONS:
--version, -v print the version
```
By default stream-tv-server listens on all ip addresses on port 8080. This means that it is exposed to the local network (LAN / WLAN) which is needed if the app is on a phone. Note that the phone must be in the same network as the computer / laptop.
By default stream-server listens on all ip addresses on port 8080. This means that it is exposed to the local network (LAN / WLAN) which is needed if the app is on a phone. Note that the phone must be in the same network as the computer / laptop.
When using the Android Emulator on the same device as the server this exposure is not necessary. Use the `--local` flag to only listen on `127.0.0.1` aka `localhost`. The emulator must then connect to `10.0.2.2` as described here:
......
# Quickstart <small>(learning by doing)</small>
```bash
$ ./stream-tv-server
$ ./stream-server
```
```
Serving on
http://127.0.0.1:8080
http://192.168.0.136:8080
Read the documentation at https://simons-nzse-2.h-da.io/stream-tv/server/usage/ on how to use this server.
http://192.168.0.66:8080
Read the quickstart at https://stream-server.h-da.io/quickstart to get started.
Stop with Ctrl-C or close this terminal.
```
!!! note
In the examples of this documentation only the local address is used. If you want to connect from your phone or the emulator you need to use the network address (`192.168.0.136` in this case). Also we assume you use the default port `8080`.
In the examples of this documentation only the local address is used. If you want to connect from your phone or the emulator you need to use the network address (`192.168.0.66` in this case). Also we assume you use the default port `8080`.
1. Open <http://127.0.0.1:8080> in a browser. Leave this tab / window open while you do the other steps.
2. Get the current state of the tv:
2. Get the current state of the display:
``` md tab="Browser"
> http://127.0.0.1:8080/tv/state
```
``` java tab="StreamTV.java" linenums="1"
StreamTV streamTV = new StreamTV("10.0.2.2:8080");
<pre><code><http://127.0.0.1:8080/display></code></pre>
``` java
StreamServerClient client = new StreamServerClient("10.0.2.2:8080");
JSONObject state = streamTV.tvState(null, null, null, null, null);
JSONObject state = client.display(null, null, null, null, null);
```
!!! example
``` json
{
......@@ -41,14 +38,9 @@ Stop with Ctrl-C or close this terminal.
3. Find some stream on twitch:
``` md tab="Browser"
> http://127.0.0.1:8080/twitch/streams/top
```
``` java tab="StreamTV.java" linenums="1"
StreamTV streamTV = new StreamTV("10.0.2.2:8080");
List<JSONObject> topStreams = streamTV.twitchStreamsTop(null, null, null); // no filters
<pre><code><http://127.0.0.1:8080/twitch/getTopStreams></code></pre>
``` java
List<JSONObject> topStreams = client.twitchGetTopStreams(null, null, null); // no filters
```
!!! example
......@@ -72,16 +64,11 @@ Stop with Ctrl-C or close this terminal.
]
```
4. Start playback of some stream with chat and muted volume:
``` md tab="Browser"
> http://127.0.0.1:8080/tv/state?large_channel={channel name here}&volume=0&show_chat=true
```
``` java tab="StreamTV.java" linenums="1"
StreamTV streamTV = new StreamTV("10.0.2.2:8080");
4. Start playback of your selected stream with chat and muted volume:
JSONObject state = streamTV.tvState("channel name here", null, 0.0f, null, true);
<pre><code><http://127.0.0.1:8080/display?large_channel={channel name here}&volume=0&show_chat=true></code></pre>
``` java
client.display("channel name here", null, 0.0f, null, true);
```
!!! example
......
# Reference
## `/tv`
## `/display`
### `/tv/state`
> Updates and returns the new state of the TV.
> Updates and returns the new state of the display.
Optional Parameters:
......@@ -19,63 +17,44 @@ Optional Parameters:
!!! note
All parameters are optional and can be combined. If none are supplied no updates are done and the current state gets returned.
Returns: [`TVState`](#tvstate_1).
Examples:
``` md tab="Browser"
Only set the large_channel to riotgames
> http://127.0.0.1:8080/tv/state?large_channel=riotgames
Set the large_channel to monstercat
Disable the small_channel
Set the volume to 0.8
The small_scale is not changed (because of its absence)
Hide the chat
> http://127.0.0.1:8080/tv/state?large_channel=monstercat&small_channel=&volume=0.8&show_chat=false
```
``` java tab="StreamTV.java" linenums="1"
StreamTV streamTV = new StreamTV("10.0.2.2:8080");
Returns [`DisplayState`](#displaystate).
// Only set the large_channel to riotgames
JSONObject newState = streamTV.tvState("riotgames", null, null, null, null);
??? example "Examples"
* Only set the large_channel to riotgames
<pre><code><http://127.0.0.1:8080/display?large_channel=riotgames></code></pre>
``` java
/* JSONObject newState = */ client.display("riotgames", null, null, null, null);
```
// Set the large_channel to monstercat
// Disable the small_channel
// Set the volume to 0.8
// The small_scale is not changed (because of null)
// Hide the chat
JSONObject newState = streamTV.tvState("monstercat", "", 0.8f, null, false);
```
* Set the large_channel to monstercat, disable the small_channel, set the volume to 0.8 and hide the chat.
Notice the small_scale is not changed (because of its absence)
<pre><code><http://127.0.0.1:8080/display?large_channel=monstercat&small_channel=&volume=0.8&show_chat=false></code></pre>
``` java
/* JSONObject newState = */ client.display("monstercat", "", 0.8f, null, false);
```
---
## `/twitch`
### `/twitch/games/top`