diff --git a/react-native/src/index.d.ts b/react-native/src/index.d.ts index 8de2b56..551b735 100644 --- a/react-native/src/index.d.ts +++ b/react-native/src/index.d.ts @@ -321,7 +321,7 @@ declare module 'ffmpeg-kit-react-native' { export class MediaInformation { - static readonly KEY_MEDIA_PROPERTIES: string; + static readonly KEY_FORMAT_PROPERTIES: string; static readonly KEY_FILENAME: string; static readonly KEY_FORMAT: string; static readonly KEY_FORMAT_LONG: string; @@ -357,9 +357,15 @@ declare module 'ffmpeg-kit-react-native' { getNumberProperty(key: string): number; - getProperties(key: string): Record; + getProperty(key: string): any; - getMediaProperties(): Record; + getStringFormatProperty(key: string): string; + + getNumberFormatProperty(key: string): number; + + getFormatProperty(key: string): any; + + getFormatProperties(): Record; getAllProperties(): Record; @@ -591,7 +597,7 @@ declare module 'ffmpeg-kit-react-native' { getNumberProperty(key): number; - getProperties(key): Record; + getProperty(key): any; getAllProperties(): Record; @@ -627,7 +633,7 @@ declare module 'ffmpeg-kit-react-native' { getNumberProperty(key): number; - getProperties(key): Record; + getProperty(key): any; getAllProperties(): Record; diff --git a/react-native/src/index.js b/react-native/src/index.js index 03241f1..041544f 100644 --- a/react-native/src/index.js +++ b/react-native/src/index.js @@ -2438,7 +2438,7 @@ export class Log { */ export class MediaInformation { - static KEY_MEDIA_PROPERTIES = "format"; + static KEY_FORMAT_PROPERTIES = "format"; static KEY_FILENAME = "filename"; static KEY_FORMAT = "format_name"; static KEY_FORMAT_LONG = "format_long_name"; @@ -2460,7 +2460,7 @@ export class MediaInformation { * @return media file name */ getFilename() { - return this.getStringProperty(MediaInformation.KEY_FILENAME); + return this.getStringFormatProperty(MediaInformation.KEY_FILENAME); } /** @@ -2469,7 +2469,7 @@ export class MediaInformation { * @return media format */ getFormat() { - return this.getStringProperty(MediaInformation.KEY_FORMAT); + return this.getStringFormatProperty(MediaInformation.KEY_FORMAT); } /** @@ -2478,7 +2478,7 @@ export class MediaInformation { * @return media long format */ getLongFormat() { - return this.getStringProperty(MediaInformation.KEY_FORMAT_LONG); + return this.getStringFormatProperty(MediaInformation.KEY_FORMAT_LONG); } /** @@ -2487,7 +2487,7 @@ export class MediaInformation { * @return media duration in "seconds.microseconds" format */ getDuration() { - return this.getStringProperty(MediaInformation.KEY_DURATION); + return this.getStringFormatProperty(MediaInformation.KEY_DURATION); } /** @@ -2496,7 +2496,7 @@ export class MediaInformation { * @return media start time in milliseconds */ getStartTime() { - return this.getStringProperty(MediaInformation.KEY_START_TIME); + return this.getStringFormatProperty(MediaInformation.KEY_START_TIME); } /** @@ -2505,7 +2505,7 @@ export class MediaInformation { * @return media size in bytes */ getSize() { - return this.getStringProperty(MediaInformation.KEY_SIZE); + return this.getStringFormatProperty(MediaInformation.KEY_SIZE); } /** @@ -2514,7 +2514,7 @@ export class MediaInformation { * @return media bitrate in kb/s */ getBitrate() { - return this.getStringProperty(MediaInformation.KEY_BIT_RATE); + return this.getStringFormatProperty(MediaInformation.KEY_BIT_RATE); } /** @@ -2523,7 +2523,7 @@ export class MediaInformation { * @return tags dictionary */ getTags() { - return this.getProperties(MediaInformation.KEY_TAGS); + return this.getFormatProperty(MediaInformation.KEY_TAGS); } /** @@ -2571,58 +2571,103 @@ export class MediaInformation { } /** - * Returns the media property associated with the key. + * Returns the property associated with the key. * * @param key property key - * @return media property as string or undefined if the key is not found + * @return property as string or undefined if the key is not found */ getStringProperty(key) { - let mediaProperties = this.getMediaProperties(); - if (mediaProperties !== undefined) { - return mediaProperties[key]; + let allProperties = this.getAllProperties(); + if (allProperties !== undefined) { + return allProperties[key]; } else { return undefined; } } /** - * Returns the media property associated with the key. + * Returns the property associated with the key. * * @param key property key - * @return media property as number or undefined if the key is not found + * @return property as number or undefined if the key is not found */ getNumberProperty(key) { - let mediaProperties = this.getMediaProperties(); - if (mediaProperties !== undefined) { - return mediaProperties[key]; + let allProperties = this.getAllProperties(); + if (allProperties !== undefined) { + return allProperties[key]; } else { return undefined; } } /** - * Returns the media properties associated with the key. + * Returns the property associated with the key. * - * @param key properties key - * @return media properties as an object or undefined if the key is not found + * @param key property key + * @return property as an object or undefined if the key is not found */ - getProperties(key) { - let mediaProperties = this.getMediaProperties(); - if (mediaProperties !== undefined) { - return mediaProperties[key]; + getProperty(key) { + let allProperties = this.getAllProperties(); + if (allProperties !== undefined) { + return allProperties[key]; } else { return undefined; } } /** - * Returns all media properties. + * Returns the format property associated with the key. * - * @returns an object where media properties can be accessed by property names + * @param key property key + * @return format property as string or undefined if the key is not found */ - getMediaProperties() { + getStringFormatProperty(key) { + let formatProperties = this.getFormatProperties(); + if (formatProperties !== undefined) { + return formatProperties[key]; + } else { + return undefined; + } + } + + /** + * Returns the format property associated with the key. + * + * @param key property key + * @return format property as number or undefined if the key is not found + */ + getNumberFormatProperty(key) { + let formatProperties = this.getFormatProperties(); + if (formatProperties !== undefined) { + return formatProperties[key]; + } else { + return undefined; + } + } + + /** + * Returns the format property associated with the key. + * + * @param key property key + * @return format property as an object or undefined if the key is not found + */ + getFormatProperty(key) { + let formatProperties = this.getFormatProperties(); + if (formatProperties !== undefined) { + return formatProperties[key]; + } else { + return undefined; + } + } + + /** + * Returns all format properties defined. + * + * @returns an object where format properties can be accessed by property names + */ + getFormatProperties() { if (this.#allProperties !== undefined) { - return this.#allProperties.format; + return this.#allProperties[MediaInformation.KEY_FORMAT_PROPERTIES]; } else { return undefined; }