@scarlett-player/core 0.5.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/scarlett-player.d.ts.map +1 -1
- package/dist/scarlett-player.js +48 -3
- package/dist/scarlett-player.js.map +1 -1
- package/dist/types/events.d.ts +45 -0
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -4
package/dist/index.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export { ErrorHandler, ErrorCode, type PlayerError } from './error-handler';
|
|
|
12
12
|
export { PluginManager, type PluginManagerOptions } from './plugin-manager';
|
|
13
13
|
export { PluginAPI, type PluginAPIDeps } from './plugin-api';
|
|
14
14
|
export { ScarlettPlayer, createPlayer, type PlayerOptions, type QualityLevel } from './scarlett-player';
|
|
15
|
-
export type { Plugin, PluginType, PluginState, PluginConfig, PluginFactory, PluginDescriptor, IPluginAPI, StateStore, StateKey, StateValue, StateUpdate, StateChangeEvent, IStateManager, PlaybackState, MediaType, MediaSource, Chapter, TextTrack, AudioTrack, SeekableRange, ThumbnailConfig, PlayerEventMap, EventName, EventPayload, EventHandler, EventInterceptor, EventSubscription, EventEmitterOptions, } from './types/index';
|
|
15
|
+
export type { Plugin, PluginType, PluginState, PluginConfig, PluginFactory, PluginDescriptor, IPluginAPI, StateStore, StateKey, StateValue, StateUpdate, StateChangeEvent, IStateManager, PlaybackState, MediaType, MediaSource, Chapter, TextTrack, AudioTrack, SeekableRange, ThumbnailConfig, PlayerEventMap, EventName, EventPayload, EventHandler, EventInterceptor, EventSubscription, EventEmitterOptions, PlaylistTrack, } from './types/index';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAG/F,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGxG,YAAY,EAEV,MAAM,EACN,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,UAAU,EAEV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,SAAS,EACT,WAAW,EACX,OAAO,EACP,SAAS,EACT,UAAU,EACV,aAAa,EACb,eAAe,EAEf,cAAc,EACd,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mapp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
|
+
this.eventBus.on("media:load-request", async ({ src, autoplay }) => {
|
|
1684
|
+
if (this.stateManager.getValue("chromecastActive")) return;
|
|
1685
|
+
await this.load(src);
|
|
1686
|
+
if (autoplay !== false) {
|
|
1687
|
+
await this.play();
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1683
1690
|
if (this.initialSrc) {
|
|
1684
1691
|
await this.load(this.initialSrc);
|
|
1685
1692
|
}
|
|
@@ -1887,8 +1894,9 @@ class ScarlettPlayer {
|
|
|
1887
1894
|
*/
|
|
1888
1895
|
setPlaybackRate(rate) {
|
|
1889
1896
|
this.checkDestroyed();
|
|
1890
|
-
|
|
1891
|
-
this.
|
|
1897
|
+
const clampedRate = Math.max(0.0625, Math.min(16, rate));
|
|
1898
|
+
this.stateManager.set("playbackRate", clampedRate);
|
|
1899
|
+
this.eventBus.emit("playback:ratechange", { rate: clampedRate });
|
|
1892
1900
|
}
|
|
1893
1901
|
/**
|
|
1894
1902
|
* Set autoplay state.
|
|
@@ -2017,6 +2025,13 @@ class ScarlettPlayer {
|
|
|
2017
2025
|
}
|
|
2018
2026
|
const provider = this._currentProvider;
|
|
2019
2027
|
if (typeof provider.setLevel === "function") {
|
|
2028
|
+
if (index !== -1) {
|
|
2029
|
+
const levels = this.getQualities();
|
|
2030
|
+
if (levels.length > 0 && (index < 0 || index >= levels.length)) {
|
|
2031
|
+
this.logger.warn(`Invalid quality index: ${index} (available: ${levels.length})`);
|
|
2032
|
+
return;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2020
2035
|
provider.setLevel(index);
|
|
2021
2036
|
this.eventBus.emit("quality:change", {
|
|
2022
2037
|
quality: index === -1 ? "auto" : `level-${index}`,
|
|
@@ -2257,18 +2272,40 @@ class ScarlettPlayer {
|
|
|
2257
2272
|
* @private
|
|
2258
2273
|
*/
|
|
2259
2274
|
detectMimeType(source) {
|
|
2260
|
-
|
|
2275
|
+
let path = source;
|
|
2276
|
+
try {
|
|
2277
|
+
path = new URL(source).pathname;
|
|
2278
|
+
} catch {
|
|
2279
|
+
const noQuery = source.split("?")[0] ?? source;
|
|
2280
|
+
path = noQuery.split("#")[0] ?? noQuery;
|
|
2281
|
+
}
|
|
2282
|
+
const ext = path.split(".").pop()?.toLowerCase() ?? "";
|
|
2261
2283
|
switch (ext) {
|
|
2262
2284
|
case "m3u8":
|
|
2263
2285
|
return "application/x-mpegURL";
|
|
2264
2286
|
case "mpd":
|
|
2265
2287
|
return "application/dash+xml";
|
|
2266
2288
|
case "mp4":
|
|
2289
|
+
case "m4v":
|
|
2267
2290
|
return "video/mp4";
|
|
2268
2291
|
case "webm":
|
|
2269
2292
|
return "video/webm";
|
|
2270
2293
|
case "ogg":
|
|
2294
|
+
case "ogv":
|
|
2271
2295
|
return "video/ogg";
|
|
2296
|
+
case "mov":
|
|
2297
|
+
return "video/quicktime";
|
|
2298
|
+
case "mkv":
|
|
2299
|
+
return "video/x-matroska";
|
|
2300
|
+
case "mp3":
|
|
2301
|
+
return "audio/mpeg";
|
|
2302
|
+
case "wav":
|
|
2303
|
+
return "audio/wav";
|
|
2304
|
+
case "flac":
|
|
2305
|
+
return "audio/flac";
|
|
2306
|
+
case "aac":
|
|
2307
|
+
case "m4a":
|
|
2308
|
+
return "audio/mp4";
|
|
2272
2309
|
default:
|
|
2273
2310
|
return "video/mp4";
|
|
2274
2311
|
}
|