str-native-video-player 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/plugin.js ADDED
@@ -0,0 +1,414 @@
1
+ var capacitorSTRTV = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const STRTV = core.registerPlugin('STRTV', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.STRTVWeb()),
6
+ });
7
+
8
+ class indexedDB_interface {
9
+ constructor(DBType, DB_version_num = 30) {
10
+ this.currentlyStoringList = [];
11
+ this.DB_version_num = DB_version_num;
12
+ this.dbType = DBType;
13
+ }
14
+ get STORE_NAME() {
15
+ return `${this.dbType}_entries`;
16
+ }
17
+ get DB_NAME() {
18
+ return `${this.dbType}_DB`;
19
+ }
20
+ convertAudSrcEntryNameToStorageName(audSrcEntry_key) {
21
+ let fps_30_blob_name = audSrcEntry_key + '_data';
22
+ if (audSrcEntry_key.includes('.')) {
23
+ fps_30_blob_name = audSrcEntry_key.split('.')[0] + '_data';
24
+ }
25
+ fps_30_blob_name = fps_30_blob_name.replace('_aud_', '_');
26
+ return fps_30_blob_name;
27
+ }
28
+ /**
29
+ * Stores the value data under the key
30
+ * @param key
31
+ * @param audSrcFloatSrc
32
+ * @returns
33
+ */
34
+ async storeInIndexedDB(key, value, operation = 'put') {
35
+ // Prevent the case of double store call
36
+ if (this.currentlyStoringList.includes(key)) {
37
+ return;
38
+ }
39
+ this.currentlyStoringList.push(key);
40
+ const db = await this.openIndexedDB();
41
+ if (!db)
42
+ return;
43
+ const transaction = db.transaction([this.STORE_NAME], 'readwrite');
44
+ const objectStore = transaction.objectStore(this.STORE_NAME);
45
+ const request = objectStore[operation]({ key: key, data: value });
46
+ return new Promise((resolve, reject) => {
47
+ request.onsuccess = () => {
48
+ // console.log('Data stored successfully');
49
+ this.currentlyStoringList = this.currentlyStoringList.filter((a) => a != key);
50
+ resolve();
51
+ };
52
+ request.onerror = (event) => {
53
+ console.error('Error storing data:', event);
54
+ reject();
55
+ };
56
+ });
57
+ }
58
+ /**
59
+ * Purges all contents from the file store
60
+ * @returns Promise<void>
61
+ */
62
+ async purgeFileStore() {
63
+ const db = await this.openIndexedDB();
64
+ if (!db)
65
+ return;
66
+ const transaction = db.transaction([this.STORE_NAME], 'readwrite');
67
+ const objectStore = transaction.objectStore(this.STORE_NAME);
68
+ return new Promise((resolve, reject) => {
69
+ const request = objectStore.clear();
70
+ request.onsuccess = () => {
71
+ resolve();
72
+ };
73
+ request.onerror = (event) => {
74
+ console.error('Error purging contents:', event);
75
+ reject();
76
+ };
77
+ });
78
+ }
79
+ async removeFromIndexedDB(key) {
80
+ this.currentlyStoringList.push(key);
81
+ const db = await this.openIndexedDB();
82
+ if (!db)
83
+ return;
84
+ const transaction = db.transaction([this.STORE_NAME], 'readwrite');
85
+ const objectStore = transaction.objectStore(this.STORE_NAME);
86
+ const request = objectStore.delete(key); // Delete the item by key
87
+ request.onsuccess = () => {
88
+ // Entry successfully deleted
89
+ this.currentlyStoringList = this.currentlyStoringList.filter((a) => a !== key);
90
+ // console.log(`Data with key "${key}" removed successfully`);
91
+ };
92
+ request.onerror = (event) => {
93
+ console.error('Error removing data:', event);
94
+ };
95
+ }
96
+ /**
97
+ * Returns true if there is an entry under that key in the IndexedDB
98
+ * @param key
99
+ * @returns
100
+ */
101
+ async doesEntryExist(key) {
102
+ const db = await this.openIndexedDB();
103
+ if (!db)
104
+ return false;
105
+ return new Promise((resolve, reject) => {
106
+ const transaction = db.transaction([this.STORE_NAME], 'readonly');
107
+ const objectStore = transaction.objectStore(this.STORE_NAME);
108
+ const request = objectStore.count(key);
109
+ request.onsuccess = (event) => {
110
+ const count = event.target.result;
111
+ resolve(count > 0); // Resolve true if count > 0 (entry exists), false otherwise
112
+ };
113
+ request.onerror = () => {
114
+ console.error('Error counting entry in IndexedDB');
115
+ reject(false);
116
+ };
117
+ });
118
+ }
119
+ /**
120
+ * Attempts closing indexed db if this.db set;
121
+ */
122
+ closeIndexedDB() {
123
+ if (!this.db)
124
+ return;
125
+ this.db.close();
126
+ this.db = null;
127
+ }
128
+ openIndexedDB() {
129
+ return new Promise((resolve) => {
130
+ if (this.db) {
131
+ resolve(this.db);
132
+ return;
133
+ }
134
+ const request = indexedDB.open(this.DB_NAME, this.DB_version_num);
135
+ request.onblocked = (event) => {
136
+ console.log('blocked ...', event); // in my case this was triggering
137
+ event.target.result.close(); // so close the connection and it worked
138
+ };
139
+ request.onupgradeneeded = (event) => {
140
+ const db = event.target.result;
141
+ if (!db.objectStoreNames.contains(this.STORE_NAME)) {
142
+ db.createObjectStore(this.STORE_NAME, { keyPath: 'key' });
143
+ }
144
+ };
145
+ request.onsuccess = (event) => {
146
+ const db = event.target.result;
147
+ this.db = db;
148
+ resolve(db);
149
+ };
150
+ request.onerror = (event) => {
151
+ console.error('Error opening IndexedDB:', event);
152
+ resolve(null);
153
+ };
154
+ });
155
+ }
156
+ /**
157
+ * Fetches from indexed db the value at the key provided from this.store_name
158
+ * @param audSrcEntry_key
159
+ * @returns
160
+ */
161
+ async getFromIndexedDB(key) {
162
+ let db = this.db;
163
+ if (!db)
164
+ db = await this.openIndexedDB();
165
+ if (!db)
166
+ return null;
167
+ return new Promise((resolve) => {
168
+ if (!db)
169
+ return null;
170
+ const transaction = db.transaction([this.STORE_NAME], 'readonly');
171
+ const objectStore = transaction.objectStore(this.STORE_NAME);
172
+ const request = objectStore.get(key);
173
+ request.onsuccess = (event) => {
174
+ try {
175
+ if (event.target.result) {
176
+ const data = event.target.result.data;
177
+ resolve(data);
178
+ }
179
+ else {
180
+ resolve(null);
181
+ }
182
+ }
183
+ catch (e) {
184
+ resolve(null);
185
+ }
186
+ };
187
+ request.onerror = (event) => {
188
+ console.error('Error fetching data:', event);
189
+ resolve(null);
190
+ };
191
+ });
192
+ }
193
+ /**
194
+ * Returns all entries in the store
195
+ * @returns array of { key, data }
196
+ */
197
+ async listEntries() {
198
+ const db = await this.openIndexedDB();
199
+ if (!db)
200
+ return [];
201
+ return new Promise((resolve) => {
202
+ const tx = db.transaction([this.STORE_NAME], 'readonly');
203
+ const store = tx.objectStore(this.STORE_NAME);
204
+ const result = [];
205
+ const request = store.openCursor();
206
+ request.onsuccess = (event) => {
207
+ const cursor = event.target.result;
208
+ if (cursor) {
209
+ result.push({ key: cursor.key, data: cursor.value.data });
210
+ cursor.continue();
211
+ }
212
+ else {
213
+ resolve(result);
214
+ }
215
+ };
216
+ request.onerror = () => {
217
+ resolve(result); // fail silently
218
+ };
219
+ });
220
+ }
221
+ }
222
+
223
+ // video-cache-coordinator.ts
224
+ class VideoCacheCoordinator {
225
+ constructor() {
226
+ this.maxCacheSizeBytes = 1000000000; // default 1 GB
227
+ this.db = new indexedDB_interface('videoCache');
228
+ }
229
+ setMaxCacheSize(bytes) {
230
+ this.maxCacheSizeBytes = bytes;
231
+ }
232
+ getMaxCacheSize() {
233
+ return this.maxCacheSizeBytes;
234
+ }
235
+ metadataKey(uuid) {
236
+ return `${uuid}_meta`;
237
+ }
238
+ blobKey(uuid) {
239
+ return `${uuid}_blob`;
240
+ }
241
+ async storeVideo(uuid, blob, url) {
242
+ const metadata = {
243
+ uuid,
244
+ sizeBytes: blob.size,
245
+ lastAccessed: Date.now(),
246
+ url,
247
+ };
248
+ // Store metadata and blob
249
+ await this.db.storeInIndexedDB(this.metadataKey(uuid), metadata);
250
+ await this.db.storeInIndexedDB(this.blobKey(uuid), blob);
251
+ await this.evictIfNeeded();
252
+ }
253
+ async getVideo(uuid) {
254
+ const metadata = await this.db.getFromIndexedDB(this.metadataKey(uuid));
255
+ if (!metadata)
256
+ return null;
257
+ // Update last accessed
258
+ metadata.lastAccessed = Date.now();
259
+ await this.db.storeInIndexedDB(this.metadataKey(uuid), metadata);
260
+ return this.db.getFromIndexedDB(this.blobKey(uuid));
261
+ }
262
+ async listVideos() {
263
+ // IndexedDB wrapper doesn’t give a `getAllKeys` method, so we can store metadata as key = uuid_meta
264
+ // For simplicity, scan all entries in the store
265
+ const allEntries = await this.db.listEntries();
266
+ // Filter for metadata entries
267
+ const videoMetas = allEntries
268
+ .filter((entry) => entry.key.endsWith('_meta'))
269
+ .map((entry) => entry.data);
270
+ return videoMetas;
271
+ }
272
+ async removeVideo(uuid) {
273
+ await this.db.removeFromIndexedDB(this.metadataKey(uuid));
274
+ await this.db.removeFromIndexedDB(this.blobKey(uuid));
275
+ }
276
+ async evictIfNeeded() {
277
+ const videos = await this.listVideos();
278
+ let totalSize = videos.reduce((acc, v) => acc + v.sizeBytes, 0);
279
+ if (totalSize <= this.maxCacheSizeBytes)
280
+ return;
281
+ // Evict LRU
282
+ videos.sort((a, b) => a.lastAccessed - b.lastAccessed);
283
+ for (const video of videos) {
284
+ await this.removeVideo(video.uuid);
285
+ totalSize -= video.sizeBytes;
286
+ if (totalSize <= this.maxCacheSizeBytes)
287
+ break;
288
+ }
289
+ }
290
+ async isCached(uuid) {
291
+ const metadata = await this.db.getFromIndexedDB(this.metadataKey(uuid));
292
+ return !!metadata;
293
+ }
294
+ }
295
+
296
+ class STRTVWeb extends core.WebPlugin {
297
+ constructor() {
298
+ super(...arguments);
299
+ this.cache_coord = new VideoCacheCoordinator();
300
+ }
301
+ async echo(options) {
302
+ console.log('ECHO', options);
303
+ return options;
304
+ }
305
+ async play_video(options) {
306
+ if (!options.video_player)
307
+ return { success: false };
308
+ const video_player = options.video_player;
309
+ // Try to get video from cache
310
+ const blob = await this.cache_coord.getVideo(options.uuid);
311
+ let url = options.url;
312
+ if (blob)
313
+ url = URL.createObjectURL(blob); // updating url with local cache url
314
+ video_player.src = url;
315
+ video_player.loop = !!options.loop;
316
+ await video_player.play();
317
+ // if (!blob && options.url) {
318
+ // this.preload_video({ uuid: options.uuid, url: options.url });
319
+ // }
320
+ return { success: true };
321
+ }
322
+ async pause_video(options) {
323
+ if (!options.video_player)
324
+ return { success: false };
325
+ options.video_player.pause();
326
+ return { success: true };
327
+ }
328
+ async stop_video(options) {
329
+ if (!options.video_player)
330
+ return { success: false };
331
+ options.video_player.src = '';
332
+ options.video_player.load();
333
+ options.video_player.pause();
334
+ return { success: true };
335
+ }
336
+ async resume_video(options) {
337
+ if (!options.video_player)
338
+ return { success: false };
339
+ options.video_player.play();
340
+ return { success: true };
341
+ }
342
+ async seek_video(options) {
343
+ if (!options.video_player)
344
+ return { success: false };
345
+ options.video_player.currentTime = options.position_ms / 1000;
346
+ return { success: true };
347
+ }
348
+ async is_video_playing() {
349
+ return { playing: false };
350
+ }
351
+ async preload_video(options) {
352
+ try {
353
+ if (await this.cache_coord.isCached(options.uuid))
354
+ return { success: true };
355
+ const resp = await fetch(options.url);
356
+ const blob = await resp.blob();
357
+ await this.cache_coord.storeVideo(options.uuid, blob, options.url);
358
+ return { success: true };
359
+ }
360
+ catch (err) {
361
+ console.error('Preload failed', err);
362
+ return { success: false };
363
+ }
364
+ }
365
+ async list_cached_videos() {
366
+ const videos = await this.cache_coord.listVideos();
367
+ return {
368
+ value: videos.map((v) => ({
369
+ uuid: v.uuid,
370
+ url: v.url || '',
371
+ size_bytes: v.sizeBytes,
372
+ last_accessed: v.lastAccessed,
373
+ })),
374
+ };
375
+ }
376
+ async evict_videos(options) {
377
+ try {
378
+ for (const uuid of options.uuids) {
379
+ await this.cache_coord.removeVideo(uuid);
380
+ }
381
+ return { success: true };
382
+ }
383
+ catch (err) {
384
+ console.error('Eviction failed', err);
385
+ return { success: false };
386
+ }
387
+ }
388
+ async get_storage_stats() {
389
+ const videos = await this.cache_coord.listVideos();
390
+ const used_bytes_videos = videos.reduce((acc, v) => acc + v.sizeBytes, 0);
391
+ return {
392
+ available_bytes: this.cache_coord.getMaxCacheSize() - used_bytes_videos,
393
+ total_bytes: this.cache_coord.getMaxCacheSize(),
394
+ used_bytes_videos,
395
+ used_bytes_app: 0,
396
+ };
397
+ }
398
+ async set_max_cache_size(options) {
399
+ this.cache_coord.setMaxCacheSize(options.max_bytes);
400
+ return { success: false };
401
+ }
402
+ }
403
+
404
+ var web = /*#__PURE__*/Object.freeze({
405
+ __proto__: null,
406
+ STRTVWeb: STRTVWeb
407
+ });
408
+
409
+ exports.STRTV = STRTV;
410
+
411
+ return exports;
412
+
413
+ })({}, capacitorExports);
414
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/IndexedDBInterface.js","esm/VideoCacheCoordinator.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\nconst STRTV = registerPlugin('STRTV', {\r\n web: () => import('./web').then((m) => new m.STRTVWeb()),\r\n});\r\nexport * from './definitions';\r\nexport { STRTV };\r\n//# sourceMappingURL=index.js.map","export class indexedDB_interface {\r\n constructor(DBType, DB_version_num = 30) {\r\n this.currentlyStoringList = [];\r\n this.DB_version_num = DB_version_num;\r\n this.dbType = DBType;\r\n }\r\n get STORE_NAME() {\r\n return `${this.dbType}_entries`;\r\n }\r\n get DB_NAME() {\r\n return `${this.dbType}_DB`;\r\n }\r\n convertAudSrcEntryNameToStorageName(audSrcEntry_key) {\r\n let fps_30_blob_name = audSrcEntry_key + '_data';\r\n if (audSrcEntry_key.includes('.')) {\r\n fps_30_blob_name = audSrcEntry_key.split('.')[0] + '_data';\r\n }\r\n fps_30_blob_name = fps_30_blob_name.replace('_aud_', '_');\r\n return fps_30_blob_name;\r\n }\r\n /**\r\n * Stores the value data under the key\r\n * @param key\r\n * @param audSrcFloatSrc\r\n * @returns\r\n */\r\n async storeInIndexedDB(key, value, operation = 'put') {\r\n // Prevent the case of double store call\r\n if (this.currentlyStoringList.includes(key)) {\r\n return;\r\n }\r\n this.currentlyStoringList.push(key);\r\n const db = await this.openIndexedDB();\r\n if (!db)\r\n return;\r\n const transaction = db.transaction([this.STORE_NAME], 'readwrite');\r\n const objectStore = transaction.objectStore(this.STORE_NAME);\r\n const request = objectStore[operation]({ key: key, data: value });\r\n return new Promise((resolve, reject) => {\r\n request.onsuccess = () => {\r\n // console.log('Data stored successfully');\r\n this.currentlyStoringList = this.currentlyStoringList.filter((a) => a != key);\r\n resolve();\r\n };\r\n request.onerror = (event) => {\r\n console.error('Error storing data:', event);\r\n reject();\r\n };\r\n });\r\n }\r\n /**\r\n * Purges all contents from the file store\r\n * @returns Promise<void>\r\n */\r\n async purgeFileStore() {\r\n const db = await this.openIndexedDB();\r\n if (!db)\r\n return;\r\n const transaction = db.transaction([this.STORE_NAME], 'readwrite');\r\n const objectStore = transaction.objectStore(this.STORE_NAME);\r\n return new Promise((resolve, reject) => {\r\n const request = objectStore.clear();\r\n request.onsuccess = () => {\r\n resolve();\r\n };\r\n request.onerror = (event) => {\r\n console.error('Error purging contents:', event);\r\n reject();\r\n };\r\n });\r\n }\r\n async removeFromIndexedDB(key) {\r\n this.currentlyStoringList.push(key);\r\n const db = await this.openIndexedDB();\r\n if (!db)\r\n return;\r\n const transaction = db.transaction([this.STORE_NAME], 'readwrite');\r\n const objectStore = transaction.objectStore(this.STORE_NAME);\r\n const request = objectStore.delete(key); // Delete the item by key\r\n request.onsuccess = () => {\r\n // Entry successfully deleted\r\n this.currentlyStoringList = this.currentlyStoringList.filter((a) => a !== key);\r\n // console.log(`Data with key \"${key}\" removed successfully`);\r\n };\r\n request.onerror = (event) => {\r\n console.error('Error removing data:', event);\r\n };\r\n }\r\n /**\r\n * Returns true if there is an entry under that key in the IndexedDB\r\n * @param key\r\n * @returns\r\n */\r\n async doesEntryExist(key) {\r\n const db = await this.openIndexedDB();\r\n if (!db)\r\n return false;\r\n return new Promise((resolve, reject) => {\r\n const transaction = db.transaction([this.STORE_NAME], 'readonly');\r\n const objectStore = transaction.objectStore(this.STORE_NAME);\r\n const request = objectStore.count(key);\r\n request.onsuccess = (event) => {\r\n const count = event.target.result;\r\n resolve(count > 0); // Resolve true if count > 0 (entry exists), false otherwise\r\n };\r\n request.onerror = () => {\r\n console.error('Error counting entry in IndexedDB');\r\n reject(false);\r\n };\r\n });\r\n }\r\n /**\r\n * Attempts closing indexed db if this.db set;\r\n */\r\n closeIndexedDB() {\r\n if (!this.db)\r\n return;\r\n this.db.close();\r\n this.db = null;\r\n }\r\n openIndexedDB() {\r\n return new Promise((resolve) => {\r\n if (this.db) {\r\n resolve(this.db);\r\n return;\r\n }\r\n const request = indexedDB.open(this.DB_NAME, this.DB_version_num);\r\n request.onblocked = (event) => {\r\n console.log('blocked ...', event); // in my case this was triggering\r\n event.target.result.close(); // so close the connection and it worked\r\n };\r\n request.onupgradeneeded = (event) => {\r\n const db = event.target.result;\r\n if (!db.objectStoreNames.contains(this.STORE_NAME)) {\r\n db.createObjectStore(this.STORE_NAME, { keyPath: 'key' });\r\n }\r\n };\r\n request.onsuccess = (event) => {\r\n const db = event.target.result;\r\n this.db = db;\r\n resolve(db);\r\n };\r\n request.onerror = (event) => {\r\n console.error('Error opening IndexedDB:', event);\r\n resolve(null);\r\n };\r\n });\r\n }\r\n /**\r\n * Fetches from indexed db the value at the key provided from this.store_name\r\n * @param audSrcEntry_key\r\n * @returns\r\n */\r\n async getFromIndexedDB(key) {\r\n let db = this.db;\r\n if (!db)\r\n db = await this.openIndexedDB();\r\n if (!db)\r\n return null;\r\n return new Promise((resolve) => {\r\n if (!db)\r\n return null;\r\n const transaction = db.transaction([this.STORE_NAME], 'readonly');\r\n const objectStore = transaction.objectStore(this.STORE_NAME);\r\n const request = objectStore.get(key);\r\n request.onsuccess = (event) => {\r\n try {\r\n if (event.target.result) {\r\n const data = event.target.result.data;\r\n resolve(data);\r\n }\r\n else {\r\n resolve(null);\r\n }\r\n }\r\n catch (e) {\r\n resolve(null);\r\n }\r\n };\r\n request.onerror = (event) => {\r\n console.error('Error fetching data:', event);\r\n resolve(null);\r\n };\r\n });\r\n }\r\n /**\r\n * Returns all entries in the store\r\n * @returns array of { key, data }\r\n */\r\n async listEntries() {\r\n const db = await this.openIndexedDB();\r\n if (!db)\r\n return [];\r\n return new Promise((resolve) => {\r\n const tx = db.transaction([this.STORE_NAME], 'readonly');\r\n const store = tx.objectStore(this.STORE_NAME);\r\n const result = [];\r\n const request = store.openCursor();\r\n request.onsuccess = (event) => {\r\n const cursor = event.target.result;\r\n if (cursor) {\r\n result.push({ key: cursor.key, data: cursor.value.data });\r\n cursor.continue();\r\n }\r\n else {\r\n resolve(result);\r\n }\r\n };\r\n request.onerror = () => {\r\n resolve(result); // fail silently\r\n };\r\n });\r\n }\r\n}\r\n//# sourceMappingURL=IndexedDBInterface.js.map","// video-cache-coordinator.ts\r\nimport { indexedDB_interface } from './IndexedDBInterface';\r\nexport class VideoCacheCoordinator {\r\n constructor() {\r\n this.maxCacheSizeBytes = 1000000000; // default 1 GB\r\n this.db = new indexedDB_interface('videoCache');\r\n }\r\n setMaxCacheSize(bytes) {\r\n this.maxCacheSizeBytes = bytes;\r\n }\r\n getMaxCacheSize() {\r\n return this.maxCacheSizeBytes;\r\n }\r\n metadataKey(uuid) {\r\n return `${uuid}_meta`;\r\n }\r\n blobKey(uuid) {\r\n return `${uuid}_blob`;\r\n }\r\n async storeVideo(uuid, blob, url) {\r\n const metadata = {\r\n uuid,\r\n sizeBytes: blob.size,\r\n lastAccessed: Date.now(),\r\n url,\r\n };\r\n // Store metadata and blob\r\n await this.db.storeInIndexedDB(this.metadataKey(uuid), metadata);\r\n await this.db.storeInIndexedDB(this.blobKey(uuid), blob);\r\n await this.evictIfNeeded();\r\n }\r\n async getVideo(uuid) {\r\n const metadata = await this.db.getFromIndexedDB(this.metadataKey(uuid));\r\n if (!metadata)\r\n return null;\r\n // Update last accessed\r\n metadata.lastAccessed = Date.now();\r\n await this.db.storeInIndexedDB(this.metadataKey(uuid), metadata);\r\n return this.db.getFromIndexedDB(this.blobKey(uuid));\r\n }\r\n async listVideos() {\r\n // IndexedDB wrapper doesn’t give a `getAllKeys` method, so we can store metadata as key = uuid_meta\r\n // For simplicity, scan all entries in the store\r\n const allEntries = await this.db.listEntries();\r\n // Filter for metadata entries\r\n const videoMetas = allEntries\r\n .filter((entry) => entry.key.endsWith('_meta'))\r\n .map((entry) => entry.data);\r\n return videoMetas;\r\n }\r\n async removeVideo(uuid) {\r\n await this.db.removeFromIndexedDB(this.metadataKey(uuid));\r\n await this.db.removeFromIndexedDB(this.blobKey(uuid));\r\n }\r\n async evictIfNeeded() {\r\n const videos = await this.listVideos();\r\n let totalSize = videos.reduce((acc, v) => acc + v.sizeBytes, 0);\r\n if (totalSize <= this.maxCacheSizeBytes)\r\n return;\r\n // Evict LRU\r\n videos.sort((a, b) => a.lastAccessed - b.lastAccessed);\r\n for (const video of videos) {\r\n await this.removeVideo(video.uuid);\r\n totalSize -= video.sizeBytes;\r\n if (totalSize <= this.maxCacheSizeBytes)\r\n break;\r\n }\r\n }\r\n async isCached(uuid) {\r\n const metadata = await this.db.getFromIndexedDB(this.metadataKey(uuid));\r\n return !!metadata;\r\n }\r\n}\r\n//# sourceMappingURL=VideoCacheCoordinator.js.map","import { WebPlugin } from '@capacitor/core';\r\nimport { VideoCacheCoordinator } from './VideoCacheCoordinator';\r\nexport class STRTVWeb extends WebPlugin {\r\n constructor() {\r\n super(...arguments);\r\n this.cache_coord = new VideoCacheCoordinator();\r\n }\r\n async echo(options) {\r\n console.log('ECHO', options);\r\n return options;\r\n }\r\n async play_video(options) {\r\n if (!options.video_player)\r\n return { success: false };\r\n const video_player = options.video_player;\r\n // Try to get video from cache\r\n const blob = await this.cache_coord.getVideo(options.uuid);\r\n let url = options.url;\r\n if (blob)\r\n url = URL.createObjectURL(blob); // updating url with local cache url\r\n video_player.src = url;\r\n video_player.loop = !!options.loop;\r\n await video_player.play();\r\n // if (!blob && options.url) {\r\n // this.preload_video({ uuid: options.uuid, url: options.url });\r\n // }\r\n return { success: true };\r\n }\r\n async pause_video(options) {\r\n if (!options.video_player)\r\n return { success: false };\r\n options.video_player.pause();\r\n return { success: true };\r\n }\r\n async stop_video(options) {\r\n if (!options.video_player)\r\n return { success: false };\r\n options.video_player.src = '';\r\n options.video_player.load();\r\n options.video_player.pause();\r\n return { success: true };\r\n }\r\n async resume_video(options) {\r\n if (!options.video_player)\r\n return { success: false };\r\n options.video_player.play();\r\n return { success: true };\r\n }\r\n async seek_video(options) {\r\n if (!options.video_player)\r\n return { success: false };\r\n options.video_player.currentTime = options.position_ms / 1000;\r\n return { success: true };\r\n }\r\n async is_video_playing() {\r\n return { playing: false };\r\n }\r\n async preload_video(options) {\r\n try {\r\n if (await this.cache_coord.isCached(options.uuid))\r\n return { success: true };\r\n const resp = await fetch(options.url);\r\n const blob = await resp.blob();\r\n await this.cache_coord.storeVideo(options.uuid, blob, options.url);\r\n return { success: true };\r\n }\r\n catch (err) {\r\n console.error('Preload failed', err);\r\n return { success: false };\r\n }\r\n }\r\n async list_cached_videos() {\r\n const videos = await this.cache_coord.listVideos();\r\n return {\r\n value: videos.map((v) => ({\r\n uuid: v.uuid,\r\n url: v.url || '',\r\n size_bytes: v.sizeBytes,\r\n last_accessed: v.lastAccessed,\r\n })),\r\n };\r\n }\r\n async evict_videos(options) {\r\n try {\r\n for (const uuid of options.uuids) {\r\n await this.cache_coord.removeVideo(uuid);\r\n }\r\n return { success: true };\r\n }\r\n catch (err) {\r\n console.error('Eviction failed', err);\r\n return { success: false };\r\n }\r\n }\r\n async get_storage_stats() {\r\n const videos = await this.cache_coord.listVideos();\r\n const used_bytes_videos = videos.reduce((acc, v) => acc + v.sizeBytes, 0);\r\n return {\r\n available_bytes: this.cache_coord.getMaxCacheSize() - used_bytes_videos,\r\n total_bytes: this.cache_coord.getMaxCacheSize(),\r\n used_bytes_videos,\r\n used_bytes_app: 0,\r\n };\r\n }\r\n async set_max_cache_size(options) {\r\n this.cache_coord.setMaxCacheSize(options.max_bytes);\r\n return { success: false };\r\n }\r\n}\r\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,KAAK,GAAGA,mBAAc,CAAC,OAAO,EAAE;IACtC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC5D,CAAC;;ICHM,MAAM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E;IAC9C,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACzD,YAAY,CAAC;IACb,YAAY,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACrC,QAAQ,CAAC;IACT,QAAQ,OAAO,GAAG,EAAE;IACpB,YAAY,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IAClD,YAAY,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACtC,QAAQ,CAAC;IACT,IAAI,CAAC;IACL,IAAI,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;IAC3D,QAAQ,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAClF,QAAQ,OAAO;IACf,YAAY,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,GAAG,iBAAiB;IACnF,YAAY,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE;IAC3D,YAAY,iBAAiB;IAC7B,YAAY,cAAc,EAAE,CAAC;IAC7B,SAAS,CAAC;IACV,IAAI,CAAC;IACL,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;IACtC,QAAQ,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5D,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClC,IAAI,CAAC;IACL;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class STRTV: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,23 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(STRTVPlugin)
9
+ public class STRTVPlugin: CAPPlugin, CAPBridgedPlugin {
10
+ public let identifier = "STRTVPlugin"
11
+ public let jsName = "STRTV"
12
+ public let pluginMethods: [CAPPluginMethod] = [
13
+ CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
14
+ ]
15
+ private let implementation = STRTV()
16
+
17
+ @objc func echo(_ call: CAPPluginCall) {
18
+ let value = call.getString("value") ?? ""
19
+ call.resolve([
20
+ "value": implementation.echo(value)
21
+ ])
22
+ }
23
+ }
@@ -0,0 +1,15 @@
1
+ import XCTest
2
+ @testable import STRTVPlugin
3
+
4
+ class STRTVTests: XCTestCase {
5
+ func testEcho() {
6
+ // This is an example of a functional test case for a plugin.
7
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
8
+
9
+ let implementation = STRTV()
10
+ let value = "Hello, World!"
11
+ let result = implementation.echo(value)
12
+
13
+ XCTAssertEqual(value, result)
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "str-native-video-player",
3
+ "version": "1.0.0",
4
+ "description": "Allows for native video player functionality, fetching and storing videos from a CDN, switching between the playback of these videos with cross fade and preloading functionality",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Sources",
14
+ "ios/Tests",
15
+ "Package.swift",
16
+ "StrNativeVideoPlayer.podspec"
17
+ ],
18
+ "author": "Lucas McKamey",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Lucasmac23/STRTV-Plugin.git.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/Lucasmac23/STRTV-Plugin.git/issues"
26
+ },
27
+ "keywords": [
28
+ "capacitor",
29
+ "plugin",
30
+ "native"
31
+ ],
32
+ "scripts": {
33
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
34
+ "verify:ios": "xcodebuild -scheme StrNativeVideoPlayer -destination generic/platform=iOS",
35
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
36
+ "verify:web": "npm run build",
37
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
38
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
39
+ "eslint": "eslint . --ext ts",
40
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
41
+ "swiftlint": "node-swiftlint",
42
+ "docgen": "docgen --api STRTVPlugin --output-readme README.md --output-json dist/docs.json",
43
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
44
+ "clean": "rimraf ./dist",
45
+ "watch": "tsc --watch",
46
+ "prepublishOnly": "npm run build"
47
+ },
48
+ "devDependencies": {
49
+ "@capacitor/android": "^7.0.0",
50
+ "@capacitor/core": "^7.0.0",
51
+ "@capacitor/docgen": "^0.3.0",
52
+ "@capacitor/ios": "^7.0.0",
53
+ "@ionic/eslint-config": "^0.4.0",
54
+ "@ionic/prettier-config": "^4.0.0",
55
+ "@ionic/swiftlint-config": "^2.0.0",
56
+ "eslint": "^8.57.0",
57
+ "prettier": "^3.4.2",
58
+ "prettier-plugin-java": "^2.6.6",
59
+ "rimraf": "^6.0.1",
60
+ "rollup": "^4.30.1",
61
+ "swiftlint": "^2.0.0",
62
+ "typescript": "~4.1.5"
63
+ },
64
+ "peerDependencies": {
65
+ "@capacitor/core": ">=7.0.0"
66
+ },
67
+ "prettier": "@ionic/prettier-config",
68
+ "swiftlint": "@ionic/swiftlint-config",
69
+ "eslintConfig": {
70
+ "extends": "@ionic/eslint-config/recommended"
71
+ },
72
+ "capacitor": {
73
+ "ios": {
74
+ "src": "ios"
75
+ },
76
+ "android": {
77
+ "src": "android"
78
+ }
79
+ }
80
+ }