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

Rebrand examples including the JS embed library namespace #4

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# SWITCHtube usage examples
# Switch Tube usage examples

Usage examples of the [SWITCHtube web service API](http://tube.switch.ch/help/api) and the [SWITCHtube JavaScript embed library](http://tube.switch.ch/help/embed).
Usage examples of the [Switch Tube web service API](http://tube.switch.ch/help/api) and the [Switch Tube JavaScript embed library](http://tube.switch.ch/help/embed).

## Web service API

- [download-channel.py](api/download-channel.py) is a Python script that illustrates basic usage of the web service. It allows you to downloading all video from a given channel using an access token from your SWITCHtube profile.
- [download-channel.py](api/download-channel.py) is a Python script that illustrates basic usage of the web service. It allows you to downloading all video from a given channel using an access token from your Switch Tube profile.
- [list-channels.py](api/list-channels.py) list channels you can contribute to.
- [upload.py](api/upload.py) allows you to upload a video to a channel you can contribute to.

## JavaScript embed library

- [Add and control player](embed/add_player.html) shows how to use the embed library to add a video player inside an existing container element on your page, and how to control playback. This is the preferred way to use the embed library from your JavaScript code. You can also view a [live demo of this example](http://embed-examples.fngtps.com/add_player.html).
- [Control existing iframe](embed/control_existing_iframe.html) uses the embed library to control playback for a video embedded using the HTML embed code from a SWITCHtube video page. You can also view a [live demo of this example](http://embed-examples.fngtps.com/control_existing_iframe.html).
- [Control existing iframe](embed/control_existing_iframe.html) uses the embed library to control playback for a video embedded using the HTML embed code from a Switch Tube video page. You can also view a [live demo of this example](http://embed-examples.fngtps.com/control_existing_iframe.html).
8 changes: 4 additions & 4 deletions api/download-channel.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Download all video from a channel using the SWITCHtube web service API.
"""Download all video from a channel using the Switch Tube web service API.

Assuming the access token `Hbmqqdc8x49Qjk1L3BKBAec`, download all video from
the channel with id `c61x4b` to a directory named `videos` by running:

$ python3 download-channel.py Hbmqqdc8x49Qjk1L3BKBAec c61x4b ./videos

This script is intended to illustrate usage of the SWITCHtube web service API
This script is intended to illustrate usage of the Switch Tube web service API
and is provided “as is”. Please see https://tube.switch.ch/api.html for more
information.

Expand Down Expand Up @@ -81,8 +81,8 @@ def download(url, path):

# Define and parse command line arguments.
parser = argparse.ArgumentParser(
description='Download all video from a SWITCHtube channel.')
parser.add_argument('token', help='access token from your SWITCHtube profile')
description='Download all video from a Switch Tube channel.')
parser.add_argument('token', help='access token from your Switch Tube profile')
parser.add_argument('channel', help='id of the channel')
parser.add_argument(
'target_directory', type=pathlib.Path, help='directory to download to')
Expand Down
8 changes: 4 additions & 4 deletions api/list-channels.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Use the SWITCHtube web service API to list channels you can contribute to.
"""Use the Switch Tube web service API to list channels you can contribute to.

Assuming the access token `Hbmqqdc8x49Qjk1L3BKBAec`, list the channels you
can contribute to:

$ python3 list-channels.py Hbmqqdc8x49Qjk1L3BKBAec

This script is intended to illustrate usage of the SWITCHtube web service API
This script is intended to illustrate usage of the Switch Tube web service API
and is provided “as is”. Please see https://tube.switch.ch/api.html for more
information.

Expand All @@ -23,8 +23,8 @@

# Define and parse command line arguments.
parser = argparse.ArgumentParser(
description='List the channels you own on SWITCHtube.')
parser.add_argument('token', help='access token from your SWITCHtube profile')
description='List the channels you own on Switch Tube.')
parser.add_argument('token', help='access token from your Switch Tube profile')
arguments = parser.parse_args()

# Get channels and show their id and title.
Expand Down
8 changes: 4 additions & 4 deletions api/upload.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Upload a video to a channel using the SWITCHtube web service API.
"""Upload a video to a channel using the Switch Tube web service API.

Assuming the access token `Hbmqqdc8x49Qjk1L3BKBAec`, upload `video.mp4` to the
channel with id `42` using `Maths 101` as its title:

$ python3 upload.py Hbmqqdc8x49Qjk1L3BKBAec 42 video.mp4 "Maths 101"

This script is intended to illustrate usage of the SWITCHtube web service API
This script is intended to illustrate usage of the Switch Tube web service API
and is provided “as is”. Please see https://tube.switch.ch/api.html for more
information.

Expand All @@ -30,8 +30,8 @@

# Define and parse command line arguments.
parser = argparse.ArgumentParser(
description='Upload a video to a SWITCHtube channel.')
parser.add_argument('token', help='access token from your SWITCHtube profile')
description='Upload a video to a Switch Tube channel.')
parser.add_argument('token', help='access token from your Switch Tube profile')
parser.add_argument('channel', help='id of the channel')
parser.add_argument('path', type=pathlib.Path, help='file to upload')
parser.add_argument('title', help='video title')
Expand Down
24 changes: 12 additions & 12 deletions embed/add_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
/* `width: 100%;` and `height: 100%` are set inline by the embed library. */
}
</style>
<!-- Load the SWITCHtube embed library asynchronous. -->
<!-- Load the Switch Tube embed library asynchronous. -->
<script async src="https://tube.switch.ch/js/embed.js"></script>
</head>
<body>

<hgroup>
<h1>SWITCHtube JS embed library</h1>
<h1>Switch Tube JS embed library</h1>
<h2>Add and control player</h2>
</hgroup>

<p>This example shows how to use the SWITCHtube embed library to add a video
<p>This example shows how to use the Switch Tube embed library to add a video
player inside an existing container element, and how to control playback. This
is the preferred way to use the embed library from your JavaScript code.</p>

Expand Down Expand Up @@ -72,10 +72,10 @@ <h2>Add and control player</h2>
let container = document.querySelector('div#video')

// Once the player has been loaded inside the iframe, the embed library
// will trigger a `SWITCHtubeEmbed:load` event on the container element.
// will trigger a `SwitchTubeEmbed:load` event on the container element.
// It is recommended to set up usage of the player control object in
// response to this event.
container.addEventListener('SWITCHtubeEmbed:load', (event) => {
container.addEventListener('SwitchTubeEmbed:load', (event) => {
// Get the player control object from the event’s `detail` property.
let player = event.detail

Expand Down Expand Up @@ -124,14 +124,14 @@ <h2>Add and control player</h2>
})
})

// With a handler for the `SWITCHtubeEmbed:load` added, the player can be
// With a handler for the `SwitchTubeEmbed:load` added, the player can be
// added and the video loaded. The `player` method requires a reference to
// the container element and a SWITCHtube video URL as its arguments.
// the container element and a SwitchTube video URL as its arguments.
//
// The `player` method returns the same player control object as is
// available from the `SWITCHtubeEmbed:load` event’s `detail` property, but
// available from the `SwitchTubeEmbed:load` event’s `detail` property, but
// this is not used here.
SWITCHtubeEmbed.player(
SwitchTubeEmbed.player(
// The reference can be an Element instance, a CSS selector, or an
// element id string. Here we’re using the element assigned above.
container,
Expand All @@ -147,15 +147,15 @@ <h2>Add and control player</h2>
// Because the embed library is loaded asynchronous, it might or might not be
// available when your code runs. This is why its usage is wrapped in the
// `addVideo` function defined above.
if (window.SWITCHtubeEmbed) {
if (window.SwitchTubeEmbed) {
// If the embed library is available, call `addVideo` directly.
addVideo()
} else {
// If the embed library is not yet available, add `addVideo` as the event
// handler for the `SWITCHtubeEmbed:ScriptLoaded` event. This event will be
// handler for the `SwitchTubeEmbed:ScriptLoaded` event. This event will be
// triggered by the embed library when it has finished loading to indicate
// that it is available for usage.
window.addEventListener('SWITCHtubeEmbed:ScriptLoaded', addVideo)
window.addEventListener('SwitchTubeEmbed:ScriptLoaded', addVideo)
}
</script>

Expand Down
8 changes: 4 additions & 4 deletions embed/control_existing_iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
<body>

<hgroup>
<h1>SWITCHtube JS embed library</h1>
<h1>Switch Tube JS embed library</h1>
<h2>Control existing iframe</h2>
</hgroup>

<p>This example shows how to use the embed library to control playback for a
video embedded using the HTML embed code from a SWITCHtube video page.</p>
video embedded using the HTML embed code from a Switch Tube video page.</p>

<!-- Embed code from a SWITCHtube video page. -->
<!-- Embed code from a Switch Tube video page. -->
<iframe width="640" height="360"
src="https://tube.switch.ch/embed/d42e0c7f?title=hide"
frameborder="0" allow="fullscreen" allowfullscreen>
Expand All @@ -64,7 +64,7 @@ <h2>Control existing iframe</h2>
<script>
// Get a player control object for the given iframe reference. This reference
// can be an Element instance, a CSS selector, or an element id string.
let player = SWITCHtubeEmbed.control('iframe')
let player = SwitchTubeEmbed.control('iframe')

// Add event handlers for the buttons. The methods on the control object will
// be available before the video player in the iframe has completed loading,
Expand Down