🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@nrk/player-elements

Package Overview
Dependencies
Maintainers
194
Versions
421
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nrk/player-elements - npm Package Compare versions

Package was removed
Sorry, it seems this package was removed from the registry
Comparing version
17.1.47
to
17.2.0
+7
-7
package.json
{
"name": "@nrk/player-elements",
"version": "17.1.47",
"version": "17.2.0",
"description": "",

@@ -18,3 +18,3 @@ "author": "",

"@nrkno/element-shadow-properties-mixin": "2.1.10",
"@nrk/player-core": "18.4.0",
"@nrk/player-core": "19.0.0",
"@nrk/psapi-contracts": "2.1.0",

@@ -25,5 +25,5 @@ "@nrk/psapi-contracts-playback": "3.7.2",

"eventemitter3": "5.0.4",
"@nrk/player-tracker": "8.1.3",
"@nrk/live-epg": "1.1.12",
"@nrk/player-psapi-client": "8.0.21"
"@nrk/player-psapi-client": "8.1.0",
"@nrk/live-epg": "1.2.0",
"@nrk/player-tracker": "8.2.0"
},

@@ -44,3 +44,3 @@ "peerDependencies": {

"@typescript-eslint/parser": "8.56.1",
"hls.js": "1.6.5",
"hls.js": "1.6.15",
"jsdom": "28.1.0",

@@ -57,4 +57,4 @@ "jsdom-global": "3.0.2",

"typedoc": "0.28.17",
"@nrk/stylelint-config": "1.0.2",
"@nrk/eslint-config": "1.1.0",
"@nrk/stylelint-config": "1.0.2",
"@nrk/ts-config": "1.0.3"

@@ -61,0 +61,0 @@ },

@@ -34,2 +34,3 @@ import { ReactiveElement } from "@nrkno/reactive-element";

switch (key) {
// Left (seek back)
case keyboardShortcuts.seekBackwards.find((k) => k === key): {

@@ -49,2 +50,3 @@ if ((event.ctrlKey || event.metaKey) && key === "j") {

}
// Right (seek fwd)
case keyboardShortcuts.seekForwards.find((k) => k === key): {

@@ -69,2 +71,3 @@ if (!target || target.nodeName !== "INPUT") {

switch (key) {
// Enter & Space (toggle play)
case keyboardShortcuts.togglePlayPause.find((k) => k === key): {

@@ -80,2 +83,3 @@ if (target?.nodeName !== "BUTTON") {

}
// K (toggle play)
case "k": {

@@ -86,2 +90,3 @@ event.preventDefault();

}
// 0-9 (jump in time)
case keyboardShortcuts.jumpInStream.find((k) => k === key): {

@@ -92,2 +97,3 @@ event.preventDefault();

}
// Home
case keyboardShortcuts.seekToStart.find((k) => k === key): {

@@ -98,2 +104,3 @@ event.preventDefault();

}
// End
case keyboardShortcuts.seekToEnd.find((k) => k === key): {

@@ -104,2 +111,3 @@ event.preventDefault();

}
// Up (volume up)
case keyboardShortcuts.volumeUp.find((k) => k === key): {

@@ -112,2 +120,3 @@ if (!target || target.nodeName !== "INPUT") {

}
// Down (volume down)
case keyboardShortcuts.volumeDown.find((k) => k === key): {

@@ -120,2 +129,3 @@ if (!target || target.nodeName !== "INPUT") {

}
// F (fullscreen toggle)
case keyboardShortcuts.toggleFullscreen.find((k) => k === key): {

@@ -129,2 +139,3 @@ if (this.player.fullscreenState?.isActive) {

}
// M (muted toggle)
case keyboardShortcuts.toggleMute.find((k) => k === key): {

@@ -135,5 +146,7 @@ event.preventDefault();

}
// C (subtitles toggle)
case "c": {
break;
}
// P (pip toggle)
case keyboardShortcuts.togglePiP.find((k) => k === key): {

@@ -148,2 +161,3 @@ event.preventDefault();

}
// A & Z (zoom)
case "a":

@@ -150,0 +164,0 @@ case "z": {

@@ -15,2 +15,3 @@ import { version as playerCoreVersion } from "@nrk/player-core/types.js";

import { preloadImage } from "../utils/preload.js";
import { isDefault } from "../utils/subtitles-roles.js";
import { parseMetadata } from "./metadata-parser.js";

@@ -35,3 +36,3 @@ import { PlaybackStateMixin } from "./playback-state-mixin.js";

const FONT_SIZE_BREAK_POINT = 500;
const PLAYER_ELEMENTS_VERSION = "17.1.47";
const PLAYER_ELEMENTS_VERSION = "17.2.0";
class PlayerElement extends DimensionsMixin(

@@ -1133,3 +1134,3 @@ FocusVisibleMixin(

const available = this.activeSession?.getAvailableSubtitles() ?? [];
const subtitles = available.find((sub) => sub.flags.isDefault);
const subtitles = available.find((sub) => isDefault(sub));
if (subtitles !== void 0) {

@@ -1323,2 +1324,3 @@ this.activeSession?.selectSubtitles(subtitles);

href: manifest._links.self.href,
streamingMode: manifest.streamingMode,
mediaURL: manifest.playable.assets[0].url,

@@ -1325,0 +1327,0 @@ statistics: manifest.statistics,

@@ -12,2 +12,3 @@ import type { Quality } from '@nrk/player-core/types.js';

export declare const NrkMediaTilgjengelighetGeoblocked = "nrkMediaTilgjengelighetGeoblocked";
export type StreamType = 'live' | 'onDemand';
export interface WebImage {

@@ -72,2 +73,3 @@ readonly uri: string;

readonly href: string;
streamingMode: StreamType;
readonly mediaURL: string;

@@ -137,2 +139,4 @@ readonly playable: PlayableElementVm;

export type SubtitlePreference = string | typeof NO_SUBTITLES | typeof UNSET_SUBTITLES;
export declare const HLS_CONTENT_TYPE = "application/vnd.apple.mpegurl";
export declare const DASH_CONTENT_TYPE = "application/dash+xml";
/** UserState represents the subset of properties and methods available on an NRK user object

@@ -139,0 +143,0 @@ * that is needed for a player when doing authenticated requests or request needing parameters

@@ -6,2 +6,4 @@ const NrkLockActiveIcon = "nrkLockActiveIcon";

const UNSET_SUBTITLES = "unset";
const HLS_CONTENT_TYPE = "application/vnd.apple.mpegurl";
const DASH_CONTENT_TYPE = "application/dash+xml";
const keyboardShortcuts = {

@@ -22,2 +24,4 @@ toggleFullscreen: ["f"],

export {
DASH_CONTENT_TYPE,
HLS_CONTENT_TYPE,
NO_SUBTITLES,

@@ -24,0 +28,0 @@ NrkLockActiveIcon,

@@ -21,3 +21,3 @@ import type { PlaybackSession } from '@nrk/player-core/session.js';

getDefaultSubtitleTrack(): Subtitles | undefined;
getNonSpokenDialogSubtitle(): Subtitles | undefined;
getTranslatedSubtitles(): Subtitles | undefined;
/**

@@ -24,0 +24,0 @@ * Toggle subtitle visibility

@@ -5,3 +5,4 @@ import { CoreEvent } from "@nrk/player-core/types.js";

import { isSafari, isTizenDevice } from "../utils/platform.js";
import { NO_SUBTITLES } from "./player-types.js";
import { isAutoSelectable, isCaptions, isDefault, tidyUpSubtitleRoles } from "../utils/subtitles-roles.js";
import { HLS_CONTENT_TYPE, NO_SUBTITLES } from "./player-types.js";
const _logger = getLogger("SubtitleState");

@@ -21,2 +22,4 @@ class SubtitleState extends ReactiveState {

#preferredSubtitle;
#contentType = HLS_CONTENT_TYPE;
#isLive = false;
constructor(session, manifest, preferredSubtitle) {

@@ -34,3 +37,7 @@ super();

if (isSafari()) {
session.once(CoreEvent.HasSubtitlesChange, () => this._applyPreferredSubtitle(preferredSubtitle));
session.once(CoreEvent.HasSubtitlesChange, () => {
console.log("HasSubtitlesChange event received, initializing subtitles");
this.subtitles = tidyUpSubtitleRoles(this.#session.getAvailableSubtitles(), this.#contentType, this.#isLive);
this._applyPreferredSubtitle(preferredSubtitle);
});
} else {

@@ -45,7 +52,7 @@ session.once(CoreEvent.SubtitlesChange, () => this._applyPreferredSubtitle(preferredSubtitle));

getDefaultSubtitleTrack() {
return this.subtitles.find((sub) => sub.flags.isDefault);
return this.subtitles.find((sub) => isDefault(sub));
}
getNonSpokenDialogSubtitle() {
getTranslatedSubtitles() {
return this.subtitles.find((subtitle) => {
return (subtitle.description === void 0 || subtitle.description === "") && subtitle.language === "no";
return subtitle.roles?.includes("translates");
});

@@ -66,8 +73,8 @@ }

const availableSubtitles = this.#session.getAvailableSubtitles();
let subtitles = availableSubtitles.find((sub) => sub.flags.isDefault);
let subtitles = availableSubtitles.find((sub) => isDefault(sub));
if (subtitles === void 0) {
subtitles = availableSubtitles.find((sub) => sub.flags.isCaptions);
subtitles = availableSubtitles.find((sub) => isCaptions(sub));
}
if (subtitles === void 0) {
subtitles = availableSubtitles.find((sub) => sub.flags.isAutoSelectable);
subtitles = availableSubtitles.find((sub) => isAutoSelectable(sub));
}

@@ -90,3 +97,6 @@ if (subtitles === void 0) {

if (manifest) {
this.#isLive = manifest.streamingMode === "live";
this.#contentType = manifest.playable.assets[0].mimeType;
if (subtitles?.length === 0 && this.#session.canAddSubtitles() && isTizenDevice()) {
_logger.log("No embedded subtitles, loading from manifest");
await addExternalSubtitles(this.#session, manifest);

@@ -97,3 +107,3 @@ }

}
subtitles = this.#session.getAvailableSubtitles();
subtitles = tidyUpSubtitleRoles(this.#session.getAvailableSubtitles(), this.#contentType, this.#isLive);
}

@@ -115,3 +125,3 @@ this.activeLabel = this.#session.getActiveSubtitles()?.label;

} else {
const defaultSubtitles = this.#session.getAvailableSubtitles().find((sub) => sub.flags.isDefault);
const defaultSubtitles = this.#session.getAvailableSubtitles().find((sub) => isDefault(sub));
if (defaultSubtitles !== void 0) {

@@ -143,4 +153,11 @@ this.#session.selectSubtitles(defaultSubtitles, { byUser: false });

const subtitles = manifest.playable.subtitles.map((sub) => {
const isCaptions = sub.type === "mix";
const isDefault = sub.defaultOn;
const isCaptionsSub = sub.type === "mix";
const isDefaultSub = sub.defaultOn;
const roles = [];
if (isCaptionsSub) {
roles.push("captions");
}
if (isDefaultSub) {
roles.push("default");
}
return {

@@ -150,6 +167,3 @@ src: sub.webVtt,

language: sub.language,
flags: {
isCaptions,
isDefault
}
roles
};

@@ -156,0 +170,0 @@ });

@@ -122,3 +122,2 @@ import { ReactiveElement } from "@nrkno/reactive-element";

this._unshadowProperties?.();
this.player = null;
super.disconnectedCallback();

@@ -125,0 +124,0 @@ }

function generateSrcSet(webImages) {
if (webImages.length === 0)
return "";
if (webImages.length === 0) return "";
if (isWebImage(webImages)) {

@@ -5,0 +4,0 @@ return webImages.map(({ uri, width }) => {

import { getLogger } from "@nrk/web-logger";
import { DASH_CONTENT_TYPE, HLS_CONTENT_TYPE } from "../player/player-types";
import { DASH_CONTENT_TYPE, HLS_CONTENT_TYPE } from "../player/player-types.js";
const DASH_ROLE_CAPTIONS = "caption";

@@ -117,3 +117,2 @@ const DASH_ROLE_MAIN = "main";

function chooseDefaultTrack(subtitles, context) {
console.log("Subtitles", subtitles);
const defaultTrack = context.isLive ? subtitles.find((subtitle) => subtitle.language === "no" && subtitle.roles?.includes(NRK_ROLE_TRANSLATES)) : subtitles.find((subtitle) => subtitle.language === "no" && subtitle.roles?.includes(NRK_ROLE_TRANSCRIBES)) ?? subtitles.find((subtitle) => subtitle.language === "no" && subtitle.roles?.includes(NRK_ROLE_TRANSLATES));

@@ -120,0 +119,0 @@ if (defaultTrack !== void 0) {

Sorry, the diff of this file is too big to display