adds chapters in media information object, fixes #196
This commit is contained in:
parent
34e924f255
commit
b8ff0d5995
@ -86,8 +86,6 @@ RCT_EXPORT_MODULE(FFmpegKitReactNativeModule);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (NSArray<NSString*>*)supportedEvents {
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
|
||||
|
38
react-native/src/index.d.ts
vendored
38
react-native/src/index.d.ts
vendored
@ -299,6 +299,8 @@ declare module 'ffmpeg-kit-react-native' {
|
||||
|
||||
getStreams(): Array<StreamInformation>;
|
||||
|
||||
getChapters(): Array<Chapter>;
|
||||
|
||||
getStringProperty(key: string): string;
|
||||
|
||||
getNumberProperty(key: string): number;
|
||||
@ -535,4 +537,40 @@ declare module 'ffmpeg-kit-react-native' {
|
||||
|
||||
}
|
||||
|
||||
export class Chapter {
|
||||
|
||||
static readonly KEY_ID: string;
|
||||
static readonly KEY_TIME_BASE: string;
|
||||
static readonly KEY_START: string;
|
||||
static readonly KEY_START_TIME: string;
|
||||
static readonly KEY_END: string;
|
||||
static readonly KEY_END_TIME: string;
|
||||
static readonly KEY_TAGS: string;
|
||||
|
||||
constructor(properties: Record<string, any>);
|
||||
|
||||
getId(): number;
|
||||
|
||||
getTimeBase(): string;
|
||||
|
||||
getStart(): number;
|
||||
|
||||
getStartTime(): string;
|
||||
|
||||
getEnd(): number;
|
||||
|
||||
getEndTime(): string;
|
||||
|
||||
getTags(): Record<string, any>;
|
||||
|
||||
getStringProperty(key): string;
|
||||
|
||||
getNumberProperty(key): number;
|
||||
|
||||
getProperties(key): Record<string, any>;
|
||||
|
||||
getAllProperties(): Record<string, any>;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
158
react-native/src/index.js
vendored
158
react-native/src/index.js
vendored
@ -1876,7 +1876,7 @@ export class FFprobeKit {
|
||||
* @return media information session created for this execution
|
||||
*/
|
||||
static async getMediaInformationAsync(path, executeCallback, logCallback, waitTimeout) {
|
||||
const commandArguments = ["-v", "error", "-hide_banner", "-print_format", "json", "-show_format", "-show_streams", "-i", path];
|
||||
const commandArguments = ["-v", "error", "-hide_banner", "-print_format", "json", "-show_format", "-show_streams", "-show_chapters", "-i", path];
|
||||
return FFprobeKit.getMediaInformationFromCommandArgumentsAsync(commandArguments, executeCallback, logCallback, waitTimeout);
|
||||
}
|
||||
|
||||
@ -2221,6 +2221,28 @@ export class MediaInformation {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chapters found as array.
|
||||
*
|
||||
* @returns Chapter array
|
||||
*/
|
||||
getChapters() {
|
||||
let list = [];
|
||||
let chapterList;
|
||||
|
||||
if (this.#allProperties !== undefined) {
|
||||
chapterList = this.#allProperties.chapters;
|
||||
}
|
||||
|
||||
if (chapterList !== undefined) {
|
||||
chapterList.forEach((chapter) => {
|
||||
list.push(new Chapter(chapter));
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the media property associated with the key.
|
||||
*
|
||||
@ -2788,3 +2810,137 @@ export class StreamInformation {
|
||||
return this.#allProperties;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Chapter class.
|
||||
*/
|
||||
export class Chapter {
|
||||
|
||||
static KEY_ID = "id";
|
||||
static KEY_TIME_BASE = "time_base";
|
||||
static KEY_START = "start";
|
||||
static KEY_START_TIME = "start_time";
|
||||
static KEY_END = "end";
|
||||
static KEY_END_TIME = "end_time";
|
||||
static KEY_TAGS = "tags";
|
||||
|
||||
#allProperties;
|
||||
|
||||
constructor(properties) {
|
||||
this.#allProperties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns id.
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
getId() {
|
||||
return this.getNumberProperty(Chapter.KEY_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns time base.
|
||||
*
|
||||
* @return time base
|
||||
*/
|
||||
getTimeBase() {
|
||||
return this.getStringProperty(Chapter.KEY_TIME_BASE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns start.
|
||||
*
|
||||
* @return start
|
||||
*/
|
||||
getStart() {
|
||||
return this.getNumberProperty(Chapter.KEY_START);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns start time.
|
||||
*
|
||||
* @return start time
|
||||
*/
|
||||
getStartTime() {
|
||||
return this.getStringProperty(Chapter.KEY_START_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns end.
|
||||
*
|
||||
* @return end
|
||||
*/
|
||||
getEnd() {
|
||||
return this.getNumberProperty(Chapter.KEY_END);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns end time.
|
||||
*
|
||||
* @return end time
|
||||
*/
|
||||
getEndTime() {
|
||||
return this.getStringProperty(Chapter.KEY_END_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all tags.
|
||||
*
|
||||
* @return tags object
|
||||
*/
|
||||
getTags() {
|
||||
return this.getProperties(StreamInformation.KEY_TAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chapter property associated with the key.
|
||||
*
|
||||
* @param key property key
|
||||
* @return chapter property as string or undefined if the key is not found
|
||||
*/
|
||||
getStringProperty(key) {
|
||||
if (this.#allProperties !== undefined) {
|
||||
return this.#allProperties[key];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chapter property associated with the key.
|
||||
*
|
||||
* @param key property key
|
||||
* @return chapter property as number or undefined if the key is not found
|
||||
*/
|
||||
getNumberProperty(key) {
|
||||
if (this.#allProperties !== undefined) {
|
||||
return this.#allProperties[key];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chapter properties associated with the key.
|
||||
*
|
||||
* @param key properties key
|
||||
* @return chapter properties as an object or undefined if the key is not found
|
||||
*/
|
||||
getProperties(key) {
|
||||
if (this.#allProperties !== undefined) {
|
||||
return this.#allProperties[key];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all properties found.
|
||||
*
|
||||
* @returns an object in which properties can be accessed by property names
|
||||
*/
|
||||
getAllProperties() {
|
||||
return this.#allProperties;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user