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

Multiple Stream Endpoints #170

Merged
merged 3 commits into from
May 11, 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
18 changes: 9 additions & 9 deletions src/demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"gh-pages": "^5.0.0",
"prettier": "^2.8.7"
"prettier": "^2.8.8"
},
"scripts": {
"start": "react-scripts start",
Expand Down
4 changes: 2 additions & 2 deletions src/demo/public/bare-minimum-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name="description"
content="Icecast Metadata JS - Javascript library that reads, parses, and queues real-time metadata from an Icecast stream."
/>
<script src="/icecast-metadata-js/icecast-metadata-player-1.15.6.main.min.js"></script>
<script src="/icecast-metadata-js/icecast-metadata-player-1.16.0.main.min.js"></script>
<style>
body {
background: linear-gradient(
Expand Down Expand Up @@ -171,7 +171,7 @@ <h1 style="margin-bottom: 0px">
</ol>
<b>Example</b>
<pre>
&lt;script src="icecast-metadata-player-1.15.6.main.min.js"&gt;&lt;/script&gt;
&lt;script src="icecast-metadata-player-1.16.0.main.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
const onMetadata = (metadata) =&gt; {
document.getElementById("metadata").innerHTML = metadata.StreamTitle;
Expand Down
2 changes: 1 addition & 1 deletion src/demo/public/cast-receiver.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
type="text/javascript"
src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"
></script>
<script src="/icecast-metadata-js/icecast-metadata-player-1.15.6.main.min.js"></script>
<script src="/icecast-metadata-js/icecast-metadata-player-1.16.0.main.min.js"></script>
<link
href="https://fonts.googleapis.com/css?family=Montserrat&display=swap"
rel="stylesheet"
Expand Down
63 changes: 44 additions & 19 deletions src/demo/public/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/>
<meta name="theme-color" content="#000000" />
<meta name="title" content="Icecast Metadata Player Demo" />
<script src="/icecast-metadata-js/icecast-metadata-player-1.15.6.main.min.js"></script>
<script src="/icecast-metadata-js/icecast-metadata-player-1.16.0.main.min.js"></script>
<script src="/icecast-metadata-js/icecast-metadata-stats-0.1.7.min.js"></script>
<script src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<link
Expand Down Expand Up @@ -179,9 +179,9 @@
</style>
<script>
let playerFormData, statsFormData;
const stationsJson = fetch("/icecast-metadata-js/stations.json")
.then((res) => res.text())
.then((text) => JSON.parse(text));
const stationsJson = fetch("/icecast-metadata-js/stations.json").then(
(res) => res.json()
);

// helper functions
const formatTime = (seconds = 0) =>
Expand Down Expand Up @@ -232,6 +232,7 @@
retryDelayRate: parseFloat(playerFormData.retryDelayRate),
retryDelayMin: parseFloat(playerFormData.retryDelayMin),
retryDelayMax: parseFloat(playerFormData.retryDelayMax),
endpointOrder: playerFormData.endpointOrder,
playbackMethod: playerFormData.playbackMethod,
};
};
Expand Down Expand Up @@ -516,7 +517,7 @@ <h1 style="margin-bottom: 0px">
</fieldset>
<div>
<fieldset name="stream-endpoint" class="column">
<legend>Stream Endpoint</legend>
<legend>Stream Endpoints</legend>
<input
class="stream-endpoint"
name="endpoint"
Expand All @@ -525,6 +526,25 @@ <h1 style="margin-bottom: 0px">
/>
<select id="stations" name="stations"></select>
</fieldset>
<fieldset name="multiple-endpoints">
<legend>Current Endpoint</legend>
<div class="row" style="width: 100%">
<input
id="current-endpoint"
disabled
style="flex-grow: 1"
/>
<select
title="Order that the next endpoint will be chosen. Only applicable when multiple endpoints are present."
id="endpointOrder"
name="endpointOrder"
style="width: 20%"
>
<option value="ordered">Ordered</option>
<option value="random">Random</option>
</select>
</div>
</fieldset>
<div class="row">
<fieldset
name="metadata-types"
Expand Down Expand Up @@ -874,7 +894,7 @@ <h1 style="margin-bottom: 0px">
</ol>
<b>Example</b>
<pre>
&lt;script src="icecast-metadata-player-1.15.6.main.min.js"&gt;&lt;/script&gt;
&lt;script src="icecast-metadata-player-1.16.0.main.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
const onMetadata = (metadata) =&gt; {
document.getElementById("metadata").innerHTML = metadata.StreamTitle;
Expand Down Expand Up @@ -1204,6 +1224,7 @@ <h1 style="margin-bottom: 0px">
// IcecastMetadataPlayer
const icyMetaIntEl = document.getElementById("icyMetaInt");
const playbackMethodEl = document.getElementById("actualPlaybackMethod");
const currentEndpointEl = document.getElementById("current-endpoint");
const metadataEl = document.getElementById("metadata");
const metadataQueueEl = document.getElementById("metadataQueue");
const currentTimeEl = document.getElementById("currentTime");
Expand Down Expand Up @@ -1251,6 +1272,7 @@ <h1 style="margin-bottom: 0px">

const onStreamStart = () => {
metadataEl.innerHTML = "";
currentEndpointEl.value = icecastMetadataPlayer.endpoint;
};

const onPlay = () => {
Expand Down Expand Up @@ -1285,18 +1307,21 @@ <h1 style="margin-bottom: 0px">

options = getFormOptions();

icecastMetadataPlayer = new IcecastMetadataPlayer(options.endpoint, {
...options,
enableLogging: true,
onStreamStart,
onPlay,
onStop,
onMetadata,
onMetadataEnqueue,
onCodecUpdate: enableCodecUpdate && onCodecUpdate,
onError,
onSwitch,
});
icecastMetadataPlayer = new IcecastMetadataPlayer(
options.endpoint.split(","),
{
...options,
enableLogging: true,
onStreamStart,
onPlay,
onStop,
onMetadata,
onMetadataEnqueue,
onCodecUpdate: enableCodecUpdate && onCodecUpdate,
onError,
onSwitch,
}
);

icecastMetadataPlayer.addEventListener("metadata", (...args) => {
console.log(args);
Expand Down Expand Up @@ -1334,7 +1359,7 @@ <h1 style="margin-bottom: 0px">
if (icecastMetadataPlayer) {
const options = getFormOptions();

icecastMetadataPlayer.switchEndpoint(options.endpoint, options);
icecastMetadataPlayer.switchEndpoint(null, options);
}
});
</script>
Expand Down
23 changes: 0 additions & 23 deletions src/demo/public/icecast-metadata-player-1.15.6.main.min.js

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions src/demo/public/icecast-metadata-player-1.16.0.main.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading