@capgo/capacitor-video-thumbnails 8.0.0 → 8.1.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.
package/README.md CHANGED
@@ -123,3 +123,7 @@ Construct a type with a set of properties K of type T
123
123
  <code>{
124
124
  [P in K]: T;
125
125
  }</code>
126
126
 
127
127
  </docgen-api>
128
+
129
+ ## Credits
130
+
131
+ This was inspired from (Expo SDK)[https://docs.expo.dev/versions/latest/sdk/video-thumbnails/]
@@ -4,13 +4,11 @@ import android.graphics.Bitmap;
4
4
  import android.media.MediaMetadataRetriever;
5
5
  import android.net.Uri;
6
6
  import android.util.Log;
7
-
8
7
  import com.getcapacitor.JSObject;
9
8
  import com.getcapacitor.Plugin;
10
9
  import com.getcapacitor.PluginCall;
11
10
  import com.getcapacitor.PluginMethod;
12
11
  import com.getcapacitor.annotation.CapacitorPlugin;
13
-
14
12
  import java.io.File;
15
13
  import java.io.FileOutputStream;
16
14
  import java.io.IOException;
@@ -25,7 +23,7 @@ import java.util.concurrent.Executors;
25
23
  public class CapgoVideoThumbnailsPlugin extends Plugin {
26
24
 
27
25
  private static final String TAG = "CapgoVideoThumbnails";
28
- private final String pluginVersion = "8.0.0";
26
+ private final String pluginVersion = "8.1.1";
29
27
  private final ExecutorService executor = Executors.newSingleThreadExecutor();
30
28
 
31
29
  @PluginMethod
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,oBAAoB,GAAG,cAAc,CACzC,sBAAsB,EACtB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;CACxE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapgoVideoThumbnailsPlugin } from './definitions';\n\nconst CapgoVideoThumbnails = registerPlugin<CapgoVideoThumbnailsPlugin>(\n 'CapgoVideoThumbnails',\n {\n web: () => import('./web').then((m) => new m.CapgoVideoThumbnailsWeb()),\n },\n);\n\nexport * from './definitions';\nexport { CapgoVideoThumbnails };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,oBAAoB,GAAG,cAAc,CAA6B,sBAAsB,EAAE;IAC9F,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;CACxE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapgoVideoThumbnailsPlugin } from './definitions';\n\nconst CapgoVideoThumbnails = registerPlugin<CapgoVideoThumbnailsPlugin>('CapgoVideoThumbnails', {\n web: () => import('./web').then((m) => new m.CapgoVideoThumbnailsWeb()),\n});\n\nexport * from './definitions';\nexport { CapgoVideoThumbnails };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,MAAM,OAAO,uBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,YAAY,CAChB,OAA+B;QAE/B,MAAM,EAAE,SAAS,EAAE,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;QAEvD,OAAO,IAAI,OA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K,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrF,CACF,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC;YAEF,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;gBACnB,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,SAAS,EAAE,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC;YAEF,KAAK,CAAC,GAAG,GAAG,SAAS,CAAC;YACtB,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n CapgoVideoThumbnailsPlugin,\n VideoThumbnailsOptions,\n VideoThumbnailsResult,\n} from './definitions';\n\nexport class CapgoVideoThumbnailsWeb\n extends WebPlugin\n implements CapgoVideoThumbnailsPlugin\n{\n async getThumbnail(\n options: VideoThumbnailsOptions,\n ): Promise<VideoThumbnailsResult> {\n const { sourceUri, time = 0, quality = 1.0 } = options;\n\n return new Promise((resolve, reject) => {\n const video = document.createElement('video');\n video.crossOrigin = 'anonymous';\n video.preload = 'metadata';\n\n video.onloadedmetadata = () => {\n // Seek to the specified time (convert ms to seconds)\n video.currentTime = time / 1000;\n };\n\n video.onseeked = () => {\n try {\n const canvas = document.createElement('canvas');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n reject(new Error('Failed to get canvas context'));\n return;\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n const dataUrl = canvas.toDataURL('image/jpeg', quality);\n\n resolve({\n uri: dataUrl,\n width: canvas.width,\n height: canvas.height,\n });\n } catch (error) {\n reject(\n new Error(\n `Failed to extract frame: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n };\n\n video.onerror = () => {\n reject(new Error(`Failed to load video from ${sourceUri}`));\n };\n\n video.src = sourceUri;\n video.load();\n });\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IACpD,KAAK,CAAC,YAAY,CAAC,OAA+B;QAChD,MAAM,EAAE,SAAS,EAAE,IAAI,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;QAEvD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAC9C,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;YAChC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC;YAE3B,KAAK,CAAC,gBAAgB,GAAG,GAAG,EAAE;gBAC5B,qDAAqD;gBACrD,KAAK,CAAC,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;YAClC,CAAC,CAAC;YAEF,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE;gBACpB,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;oBAChD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;oBAChC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC;oBAElC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBACpC,IAAI,CAAC,GAAG,EAAE,CAAC;wBACT,MAAM,CAAC,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;wBAClD,OAAO;oBACT,CAAC;oBAED,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;oBAExD,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;oBAExD,OAAO,CAAC;wBACN,GAAG,EAAE,OAAO;wBACZ,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,MAAM,EAAE,MAAM,CAAC,MAAM;qBACtB,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC1G,CAAC;YACH,CAAC,CAAC;YAEF,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;gBACnB,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,SAAS,EAAE,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC;YAEF,KAAK,CAAC,GAAG,GAAG,SAAS,CAAC;YACtB,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapgoVideoThumbnailsPlugin, VideoThumbnailsOptions, VideoThumbnailsResult } from './definitions';\n\nexport class CapgoVideoThumbnailsWeb extends WebPlugin implements CapgoVideoThumbnailsPlugin {\n async getThumbnail(options: VideoThumbnailsOptions): Promise<VideoThumbnailsResult> {\n const { sourceUri, time = 0, quality = 1.0 } = options;\n\n return new Promise((resolve, reject) => {\n const video = document.createElement('video');\n video.crossOrigin = 'anonymous';\n video.preload = 'metadata';\n\n video.onloadedmetadata = () => {\n // Seek to the specified time (convert ms to seconds)\n video.currentTime = time / 1000;\n };\n\n video.onseeked = () => {\n try {\n const canvas = document.createElement('canvas');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n reject(new Error('Failed to get canvas context'));\n return;\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n const dataUrl = canvas.toDataURL('image/jpeg', quality);\n\n resolve({\n uri: dataUrl,\n width: canvas.width,\n height: canvas.height,\n });\n } catch (error) {\n reject(new Error(`Failed to extract frame: ${error instanceof Error ? error.message : String(error)}`));\n }\n };\n\n video.onerror = () => {\n reject(new Error(`Failed to load video from ${sourceUri}`));\n };\n\n video.src = sourceUri;\n video.load();\n });\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
@@ -9,7 +9,7 @@ import UIKit
9
9
  */
10
10
  @objc(CapgoVideoThumbnailsPlugin)
11
11
  public class CapgoVideoThumbnailsPlugin: CAPPlugin, CAPBridgedPlugin {
12
- private let pluginVersion: String = "8.0.0"
12
+ private let pluginVersion: String = "8.1.1"
13
13
  public let identifier = "CapgoVideoThumbnailsPlugin"
14
14
  public let jsName = "CapgoVideoThumbnails"
15
15
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-video-thumbnails",
3
- "version": "8.0.0",
3
+ "version": "8.1.1",
4
4
  "description": "Generate video thumbnails from local or remote video files",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",