@ngxsplayer/ngx-smart-player-offline 0.1.0 → 0.2.1
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.
|
@@ -1,58 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
1
|
+
var OfflinePlugin = class {
|
|
2
|
+
id = "offline";
|
|
3
|
+
async onInit(ctx) {
|
|
4
|
+
ctx.facade.offline = {
|
|
5
|
+
list: () => listDownloads(),
|
|
6
|
+
download: (contentId) => downloadCurrent(ctx, contentId),
|
|
7
|
+
remove: (contentId) => removeDownload(contentId)
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
11
|
async function ensureShakaStorage() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return { Storage: shaka.offline.Storage };
|
|
12
|
+
const shakaModule = await import("shaka-player");
|
|
13
|
+
const shaka = shakaModule.default ?? shakaModule;
|
|
14
|
+
if (!shaka?.offline?.Storage) throw new Error("Shaka offline not available");
|
|
15
|
+
return { Storage: shaka.offline.Storage };
|
|
17
16
|
}
|
|
18
17
|
async function listDownloads() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const { Storage } = await ensureShakaStorage();
|
|
19
|
+
const storage = new Storage();
|
|
20
|
+
const list = await storage.list();
|
|
21
|
+
await storage.destroy();
|
|
22
|
+
return list.map((x) => ({
|
|
23
|
+
offlineUri: x.offlineUri,
|
|
24
|
+
originalUri: x.originalUri,
|
|
25
|
+
appMetadata: x.appMetadata
|
|
26
|
+
}));
|
|
24
27
|
}
|
|
25
28
|
async function downloadCurrent(ctx, contentId) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const storage = new Storage();
|
|
38
|
-
storage.configure({ offline: { usePersistentLicense: !!s.drm?.persistentLicense } });
|
|
39
|
-
const offlineUri = await storage.store(s.url, { contentId }).then((c) => c.offlineUri);
|
|
40
|
-
await storage.destroy();
|
|
41
|
-
return { offlineUri };
|
|
29
|
+
const s = ctx.config.source;
|
|
30
|
+
if (!s.url) throw new Error("offline download requires source.url");
|
|
31
|
+
if (s.live) throw new Error("offline download is VOD-only");
|
|
32
|
+
if (!s.offlineEligible) throw new Error("source.offlineEligible is false");
|
|
33
|
+
if (s.drm && s.drm.persistentLicense !== true) throw new Error("DRM content requires persistentLicense=true to attempt offline");
|
|
34
|
+
const { Storage } = await ensureShakaStorage();
|
|
35
|
+
const storage = new Storage();
|
|
36
|
+
storage.configure({ offline: { usePersistentLicense: !!s.drm?.persistentLicense } });
|
|
37
|
+
const offlineUri = await storage.store(s.url, { contentId }).then((c) => c.offlineUri);
|
|
38
|
+
await storage.destroy();
|
|
39
|
+
return { offlineUri };
|
|
42
40
|
}
|
|
43
41
|
async function removeDownload(contentId) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
await storage.remove(found.offlineUri);
|
|
50
|
-
await storage.destroy();
|
|
42
|
+
const { Storage } = await ensureShakaStorage();
|
|
43
|
+
const storage = new Storage();
|
|
44
|
+
const found = (await storage.list()).find((x) => x.appMetadata?.contentId === contentId);
|
|
45
|
+
if (found) await storage.remove(found.offlineUri);
|
|
46
|
+
await storage.destroy();
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Generated bundle index. Do not edit.
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
48
|
export { OfflinePlugin };
|
|
58
|
-
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=ngxsplayer-ngx-smart-player-offline.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxsplayer-ngx-smart-player-offline.mjs","sources":["../../../projects/ngx-smart-player-offline/src/lib/offline.plugin.ts"
|
|
1
|
+
{"version":3,"file":"ngxsplayer-ngx-smart-player-offline.mjs","names":[],"sources":["../../../projects/ngx-smart-player-offline/src/lib/offline.plugin.ts"],"sourcesContent":["import { PlayerPlugin, PlayerContext } from '@ngxsp/core';\n\nexport class OfflinePlugin implements PlayerPlugin {\n id = 'offline';\n\n async onInit(ctx: PlayerContext): Promise<void> {\n (ctx.facade as any).offline = {\n list: () => listDownloads(),\n download: (contentId: string) => downloadCurrent(ctx, contentId),\n remove: (contentId: string) => removeDownload(contentId)\n };\n }\n}\n\nasync function ensureShakaStorage(): Promise<{ Storage: any }> {\n const shakaModule: any = await import('shaka-player');\n const shaka: any = (shakaModule as any).default ?? shakaModule;\n if (!shaka?.offline?.Storage) throw new Error('Shaka offline not available');\n return { Storage: shaka.offline.Storage };\n}\n\nasync function listDownloads(): Promise<Array<{ offlineUri: string; originalUri: string; appMetadata?: any }>> {\n const { Storage } = await ensureShakaStorage();\n const storage = new Storage();\n const list = await storage.list();\n await storage.destroy();\n return list.map((x: any) => ({ offlineUri: x.offlineUri, originalUri: x.originalUri, appMetadata: x.appMetadata }));\n}\n\nasync function downloadCurrent(ctx: PlayerContext, contentId: string): Promise<{ offlineUri: string }> {\n const s = ctx.config.source;\n if (!s.url) throw new Error('offline download requires source.url');\n if (s.live) throw new Error('offline download is VOD-only');\n if (!s.offlineEligible) throw new Error('source.offlineEligible is false');\n if (s.drm && s.drm.persistentLicense !== true) {\n throw new Error('DRM content requires persistentLicense=true to attempt offline');\n }\n\n const { Storage } = await ensureShakaStorage();\n const storage = new Storage();\n storage.configure({ offline: { usePersistentLicense: !!s.drm?.persistentLicense } });\n\n const offlineUri = await storage.store(s.url, { contentId }).then((c: any) => c.offlineUri);\n await storage.destroy();\n return { offlineUri };\n}\n\nasync function removeDownload(contentId: string): Promise<void> {\n const { Storage } = await ensureShakaStorage();\n const storage = new Storage();\n const list = await storage.list();\n const found = list.find((x: any) => x.appMetadata?.contentId === contentId);\n if (found) await storage.remove(found.offlineUri);\n await storage.destroy();\n}\n"],"mappings":"AAEA,IAAa,gBAAb,MAA0B;CACxB,KAAK;CAEL,MAAM,OAAO,KAAkB;EAC5B,IAAI,OAAe,UAAU;GAC5B,YAAY,cAAa;GACzB,WAAW,cAAsB,gBAAgB,KAAK,SAAS;GAC/D,SAAS,cAAsB,eAAe,SAAS;EACxD;CACH;AACD;AAED,eAAe,qBAAkB;CAC/B,MAAM,cAAmB,MAAM,OAAO;CACtC,MAAM,QAAc,YAAoB,WAAW;CACnD,IAAI,CAAC,OAAO,SAAS,SAAS,MAAM,IAAI,MAAM,6BAA6B;CAC3E,OAAO,EAAE,SAAS,MAAM,QAAQ,QAAO;AACzC;AAEA,eAAe,gBAAa;CAC1B,MAAM,EAAE,YAAY,MAAM,mBAAkB;CAC5C,MAAM,UAAU,IAAI,QAAO;CAC3B,MAAM,OAAO,MAAM,QAAQ,KAAI;CAC/B,MAAM,QAAQ,QAAO;CACrB,OAAO,KAAK,KAAK,OAAY;EAAE,YAAY,EAAE;EAAY,aAAa,EAAE;EAAa,aAAa,EAAE;CAAW,EAAG;AACpH;AAEA,eAAe,gBAAgB,KAAoB,WAAiB;CAClE,MAAM,IAAI,IAAI,OAAO;CACrB,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI,MAAM,sCAAsC;CAClE,IAAI,EAAE,MAAM,MAAM,IAAI,MAAM,8BAA8B;CAC1D,IAAI,CAAC,EAAE,iBAAiB,MAAM,IAAI,MAAM,iCAAiC;CACzE,IAAI,EAAE,OAAO,EAAE,IAAI,sBAAsB,MACvC,MAAM,IAAI,MAAM,gEAAgE;CAGlF,MAAM,EAAE,YAAY,MAAM,mBAAkB;CAC5C,MAAM,UAAU,IAAI,QAAO;CAC3B,QAAQ,UAAU,EAAE,SAAS,EAAE,sBAAsB,CAAC,CAAC,EAAE,KAAK,kBAAiB,EAAE,CAAE;CAEnF,MAAM,aAAa,MAAM,QAAQ,MAAM,EAAE,KAAK,EAAE,UAAS,CAAE,CAAC,CAAC,MAAM,MAAW,EAAE,UAAU;CAC1F,MAAM,QAAQ,QAAO;CACrB,OAAO,EAAE,WAAU;AACrB;AAEA,eAAe,eAAe,WAAiB;CAC7C,MAAM,EAAE,YAAY,MAAM,mBAAkB;CAC5C,MAAM,UAAU,IAAI,QAAO;CAE3B,MAAM,SAAQ,MADK,QAAQ,KAAI,EACjB,CAAK,MAAM,MAAW,EAAE,aAAa,cAAc,SAAS;CAC1E,IAAI,OAAO,MAAM,QAAQ,OAAO,MAAM,UAAU;CAChD,MAAM,QAAQ,QAAO;AACvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngxsplayer/ngx-smart-player-offline",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Offline media download, listing, and removal support for ngx-smart-player.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@angular/common": ">=17.
|
|
16
|
-
"@angular/core": ">=17.
|
|
15
|
+
"@angular/common": ">=17.1.0 <23.0.0",
|
|
16
|
+
"@angular/core": ">=17.1.0 <23.0.0",
|
|
17
17
|
"rxjs": ">=7.0.0 <8.0.0",
|
|
18
18
|
"shaka-player": "^5.0.2",
|
|
19
|
-
"@ngxsplayer/ngx-smart-player": "^0.1
|
|
20
|
-
"@ngxsp/core": "^0.1
|
|
19
|
+
"@ngxsplayer/ngx-smart-player": "^0.2.1",
|
|
20
|
+
"@ngxsp/core": "^0.2.1"
|
|
21
21
|
},
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"dependencies": {
|
|
@@ -29,14 +29,15 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"module": "fesm2022/ngxsplayer-ngx-smart-player-offline.mjs",
|
|
32
|
-
"typings": "
|
|
32
|
+
"typings": "types/ngxsplayer-ngx-smart-player-offline.d.ts",
|
|
33
33
|
"exports": {
|
|
34
34
|
"./package.json": {
|
|
35
35
|
"default": "./package.json"
|
|
36
36
|
},
|
|
37
37
|
".": {
|
|
38
|
-
"types": "./
|
|
38
|
+
"types": "./types/ngxsplayer-ngx-smart-player-offline.d.ts",
|
|
39
39
|
"default": "./fesm2022/ngxsplayer-ngx-smart-player-offline.mjs"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"type": "module"
|
|
42
43
|
}
|