icecast-metadata-player
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "icecast-metadata-player", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Simple to use Javascript class that plays an Icecast stream with real-time metadata updates", | ||
@@ -16,3 +16,3 @@ "keywords": [ | ||
"scripts": { | ||
"format": "prettier --write '**/*.*js*'", | ||
"format": "prettier --write '**/*.*js*' --write '**/*.*ts*'", | ||
"update-version": "find ../demo -iname 'icecast-metadata-player*' -exec rm \"{}\" \\; && find ./ ../demo -name '.map' -prune -o -name '.git' -prune -o -name 'node_modules' -prune -o -name 'build' -prune -o -name 'package*' -prune -o -type f -printf '\\n%p:' -exec sed -i \"s/icecast-metadata-player-[0-9].[0-9].[0-9]/icecast-metadata-player-$npm_package_version/g w /dev/fd/2\" \"{}\" \\; && cp ./build/*.js ./build/*.map ../demo/public/", | ||
@@ -22,2 +22,5 @@ "build": "rm -f ./build/* && webpack && npm run update-version" | ||
"browser": "./src/IcecastMetadataPlayer.js", | ||
"main": "./src/IcecastMetadataPlayer.js", | ||
"types": "./types/icecast-metadata-player.d.ts", | ||
"type": "module", | ||
"repository": { | ||
@@ -24,0 +27,0 @@ "type": "git", |
@@ -66,3 +66,3 @@ # Icecast Metadata Player | ||
``` | ||
```javascript | ||
import IcecastMetadataPlayer from "icecast-metadata-player"; | ||
@@ -77,3 +77,3 @@ | ||
### Install as a standalone script | ||
1. Download the <a href="https://raw.githubusercontent.com/eshaz/icecast-metadata-js/master/src/icecast-metadata-player/build/icecast-metadata-player-1.3.0.min.js" download>latest build</a>. | ||
1. Download the <a href="https://raw.githubusercontent.com/eshaz/icecast-metadata-js/master/src/icecast-metadata-player/build/icecast-metadata-player-1.3.1.min.js" download>latest build</a>. | ||
2. Include the file in a `<script>` tag in your html. | ||
@@ -84,4 +84,4 @@ 3. `IcecastMetadataPlayer` is made available as a global variable in your webpage to use wherever. | ||
``` | ||
<script src="icecast-metadata-player-1.3.0.min.js"></script> | ||
```html | ||
<script src="icecast-metadata-player-1.3.1.min.js"></script> | ||
<script> | ||
@@ -109,3 +109,3 @@ const onMetadata = (metadata) => { | ||
``` | ||
```javascript | ||
const player = new IcecastMetadataPlayer("https://stream.example.com", { | ||
@@ -122,3 +122,3 @@ onMetadata: (metadata) => {console.log(metadata)}, | ||
``` | ||
```javascript | ||
const player = new IcecastMetadataPlayer("https://stream.example.com/stream.mp3", { | ||
@@ -135,3 +135,3 @@ onMetadata: (metadata) => {console.log(metadata)}, | ||
``` | ||
```javascript | ||
const player = new IcecastMetadataPlayer("https://stream.example.com/stream.opus", { | ||
@@ -148,3 +148,3 @@ onMetadata: (metadata) => {console.log(metadata)}, | ||
``` | ||
```javascript | ||
const player = new IcecastMetadataPlayer("https://stream.example.com/stream.flac", { | ||
@@ -163,3 +163,3 @@ onMetadata: (metadata) => {console.log(metadata)}, | ||
``` | ||
```javascript | ||
const player = new IcecastMetadataPlayer("https://stream.example.com/stream.flac", { | ||
@@ -177,3 +177,3 @@ onMetadata: (metadata) => {console.log(metadata)}, | ||
#### Metadata | ||
``` | ||
```javascript | ||
{ | ||
@@ -190,3 +190,3 @@ StreamTitle: "The stream's title", // ICY | ||
``` | ||
```javascript | ||
player.stop(); | ||
@@ -255,4 +255,4 @@ ``` | ||
* `player.metadataQueue` | ||
* Returns the array of `metadata` objects in FIFO order. | ||
``` | ||
* Returns the array of enqueued `metadata` in FIFO order. | ||
```javascript | ||
[ | ||
@@ -281,3 +281,3 @@ { | ||
``` | ||
```javascript | ||
const player_1 = new IcecastMetadataPlayer("https://example.com/stream_1", { | ||
@@ -309,7 +309,7 @@ ...options, | ||
* `retryDelayMin` (optional) - **Default** `0.5` seconds | ||
* Minimum number of seconds between retries (start of the exponential back-off curve) | ||
* Minimum number of seconds between retries (start of the exponential back-off curve) | ||
* `retryDelayMax` (optional) - **Default** `2` seconds | ||
* Maximum number of seconds between retries (start of the exponential back-off curve) | ||
* Maximum number of seconds between retries (end of the exponential back-off curve) | ||
* `retryDelayRate` (optional) - **Default** `0.1` i.e. 10% | ||
* Percentage of seconds to increment after each retry (how quickly to increase the back-off) | ||
* Percentage of seconds to increment after each retry (how quickly to increase the back-off) | ||
@@ -373,5 +373,5 @@ #### Metadata Options | ||
``` | ||
```javascript | ||
player.addEventListener('metadata', (event) => { | ||
const [metadata, timestampOffset, timestamp] = event.details; | ||
const [metadata, timestampOffset, timestamp] = event.detail; | ||
}) | ||
@@ -389,3 +389,3 @@ ``` | ||
IcecastMetadataPlayer builds are supplied with a source map, which allows the minified code to be viewed as fully formatted code in a browser debugger. | ||
* To enable the source map, simply copy `icecast-metadata-player-1.3.0.min.js.map` located in the build folder of this project to the location along side `icecast-metadata-player-1.3.0.min.js` in your website. | ||
* To enable the source map, simply copy `icecast-metadata-player-1.3.1.min.js.map` located in the build folder of this project to the location along side `icecast-metadata-player-1.3.1.min.js` in your website. | ||
* The source map can be used to step through and debug the code as well as see the full variable names and file origin on stack traces if you are facing any issues. | ||
@@ -392,0 +392,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { event, fireEvent } from "./global"; | ||
import { event, fireEvent } from "./global.js"; | ||
@@ -3,0 +3,0 @@ export default class FrameQueue { |
@@ -21,2 +21,3 @@ /** | ||
import { IcecastMetadataQueue } from "icecast-metadata-js"; | ||
import { | ||
@@ -47,8 +48,7 @@ p, | ||
abortController, | ||
} from "./global"; | ||
} from "./global.js"; | ||
import { IcecastMetadataQueue } from "icecast-metadata-js"; | ||
import EventTargetPolyfill from "./EventTargetPolyfill"; | ||
import MediaSourcePlayer from "./players/MediaSourcePlayer"; | ||
import HTML5Player from "./players/HTML5Player"; | ||
import EventTargetPolyfill from "./EventTargetPolyfill.js"; | ||
import MediaSourcePlayer from "./players/MediaSourcePlayer.js"; | ||
import HTML5Player from "./players/HTML5Player.js"; | ||
@@ -88,2 +88,7 @@ let EventClass; | ||
* @param {number} options.icyDetectionTimeout ICY metadata detection timeout | ||
* @param {number} options.retryTimeout Number of seconds to wait before giving up on retries | ||
* @param {number} options.retryDelayRate Percentage of seconds to increment after each retry (how quickly to increase the back-off) | ||
* @param {number} options.retryDelayMin Minimum number of seconds between retries (start of the exponential back-off curve) | ||
* @param {number} options.retryDelayMax Maximum number of seconds between retries (end of the exponential back-off curve) | ||
* @param {number} options.enableLogging Set to `true` to enable warning and error logging to the console | ||
* | ||
@@ -90,0 +95,0 @@ * @callback options.onMetadata Called with metadata when synchronized with the audio |
@@ -1,4 +0,4 @@ | ||
import { p, state, event, fireEvent, abortController } from "../global"; | ||
import Player from "./Player"; | ||
import CodecParser from "codec-parser"; | ||
import { p, state, event, fireEvent, abortController } from "../global.js"; | ||
import Player from "./Player.js"; | ||
@@ -5,0 +5,0 @@ export default class HTML5Player extends Player { |
@@ -1,6 +0,6 @@ | ||
import { state, event, fireEvent } from "../global"; | ||
import Player from "./Player"; | ||
import FrameQueue from "../FrameQueue"; | ||
import MSEAudioWrapper from "mse-audio-wrapper"; | ||
import CodecParser from "codec-parser"; | ||
import { state, event, fireEvent } from "../global.js"; | ||
import Player from "./Player.js"; | ||
import FrameQueue from "../FrameQueue.js"; | ||
@@ -7,0 +7,0 @@ const BUFFER = 10; // seconds of audio to store in SourceBuffer |
@@ -0,1 +1,2 @@ | ||
import { IcecastReadableStream } from "icecast-metadata-js"; | ||
import { | ||
@@ -13,4 +14,3 @@ p, | ||
abortController, | ||
} from "../global"; | ||
import { IcecastReadableStream } from "icecast-metadata-js"; | ||
} from "../global.js"; | ||
@@ -17,0 +17,0 @@ export default class Player { |
@@ -1,6 +0,7 @@ | ||
const path = require("path"); | ||
const webpack = require("webpack"); | ||
const TerserPlugin = require("terser-webpack-plugin"); | ||
const package = require("./package.json"); | ||
import webpack from "webpack"; | ||
import TerserPlugin from "terser-webpack-plugin"; | ||
import fs from "fs"; | ||
const packageJson = JSON.parse(fs.readFileSync("./package.json")); | ||
const license = ` | ||
@@ -26,3 +27,3 @@ * Copyright 2021 Ethan Halsall | ||
module.exports = { | ||
export default { | ||
mode: "production", | ||
@@ -32,4 +33,4 @@ devtool: "source-map", | ||
output: { | ||
path: __dirname + "/build", | ||
filename: `${package.name}-${package.version}.min.js`, | ||
path: new URL("build", import.meta.url).pathname, | ||
filename: `${packageJson.name}-${packageJson.version}.min.js`, | ||
library: "IcecastMetadataPlayer", | ||
@@ -36,0 +37,0 @@ libraryExport: "default", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
73828
13
1256
Yes
1