@ngxsplayer/ngx-smart-player-offline 0.0.1-next.0 → 0.2.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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cedvict
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -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,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AQ,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,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngxsplayer/ngx-smart-player-offline",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Offline
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Offline media download, listing, and removal support for ngx-smart-player.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
7
|
+
"audio",
|
|
8
|
+
"media",
|
|
7
9
|
"video",
|
|
8
10
|
"player",
|
|
9
11
|
"ngx-smart-player"
|
|
10
12
|
],
|
|
11
13
|
"license": "MIT",
|
|
12
14
|
"peerDependencies": {
|
|
13
|
-
"@angular/common": ">=
|
|
14
|
-
"@angular/core": ">=
|
|
15
|
-
"rxjs": ">=7.0.0",
|
|
16
|
-
"shaka-player": "
|
|
17
|
-
"@ngxsplayer/ngx-smart-player": "0.
|
|
18
|
-
"@ngxsp/core": "0.
|
|
15
|
+
"@angular/common": ">=17.1.0 <23.0.0",
|
|
16
|
+
"@angular/core": ">=17.1.0 <23.0.0",
|
|
17
|
+
"rxjs": ">=7.0.0 <8.0.0",
|
|
18
|
+
"shaka-player": "^5.0.2",
|
|
19
|
+
"@ngxsplayer/ngx-smart-player": "^0.2.0",
|
|
20
|
+
"@ngxsp/core": "^0.2.0"
|
|
19
21
|
},
|
|
20
22
|
"sideEffects": false,
|
|
21
23
|
"dependencies": {
|
|
@@ -27,14 +29,15 @@
|
|
|
27
29
|
}
|
|
28
30
|
},
|
|
29
31
|
"module": "fesm2022/ngxsplayer-ngx-smart-player-offline.mjs",
|
|
30
|
-
"typings": "
|
|
32
|
+
"typings": "types/ngxsplayer-ngx-smart-player-offline.d.ts",
|
|
31
33
|
"exports": {
|
|
32
34
|
"./package.json": {
|
|
33
35
|
"default": "./package.json"
|
|
34
36
|
},
|
|
35
37
|
".": {
|
|
36
|
-
"types": "./
|
|
38
|
+
"types": "./types/ngxsplayer-ngx-smart-player-offline.d.ts",
|
|
37
39
|
"default": "./fesm2022/ngxsplayer-ngx-smart-player-offline.mjs"
|
|
38
40
|
}
|
|
39
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"type": "module"
|
|
40
43
|
}
|