Bug fix: update waveform after fetching audio from Youtube
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Rob Watson 2022-01-25 22:47:26 +01:00
parent 5a1ebb7c3a
commit 404c11909b
6 changed files with 275 additions and 316 deletions

View File

@ -88,6 +88,41 @@ function App(): JSX.Element {
console.log('got media set:', mediaSet); console.log('got media set:', mediaSet);
setMediaSet(mediaSet); setMediaSet(mediaSet);
// fetch audio asynchronously
console.log('fetching audio...');
const audioProgressStream = service.GetPeaks({
id: mediaSet.id,
numBins: CanvasLogicalWidth,
});
const peaks = audioProgressStream.pipe(map((progress) => progress.peaks));
setOverviewPeaks(peaks);
const audioPipe = audioProgressStream.pipe(
first((progress: GetPeaksProgress) => progress.url != '')
);
const fetchAudioTask = firstValueFrom(audioPipe);
// fetch video asynchronously
console.log('fetching video...');
const videoProgressStream = service.GetVideo({ id: mediaSet.id });
const videoPipe = videoProgressStream.pipe(
first((progress: GetVideoProgress) => progress.url != '')
);
const fetchVideoTask = firstValueFrom(videoPipe);
// wait for both audio, then video.
const audioProgress = await fetchAudioTask;
audio.src = audioProgress.url;
audio.muted = false;
audio.volume = 1;
console.log('set audio src', audioProgress.url);
setMediaSet({ ...mediaSet, audioFrames: audioProgress.audioFrames });
const videoProgress = await fetchVideoTask;
video.src = videoProgress.url;
console.log('set video src', videoProgress.url);
})(); })();
}, []); }, []);
@ -131,53 +166,6 @@ function App(): JSX.Element {
return () => document.removeEventListener('keypress', handleKeyPress); return () => document.removeEventListener('keypress', handleKeyPress);
}, [selection, playState]); }, [selection, playState]);
// load audio when MediaSet is loaded:
useEffect(() => {
(async function () {
if (mediaSet == null) {
return;
}
console.log('fetching audio...');
const service = new MediaSetServiceClientImpl(newRPC());
const audioProgressStream = service.GetPeaks({
id: mediaSet.id,
numBins: CanvasLogicalWidth,
});
const peaks = audioProgressStream.pipe(map((progress) => progress.peaks));
setOverviewPeaks(peaks);
const pipe = audioProgressStream.pipe(
first((progress: GetPeaksProgress) => progress.url != '')
);
const progressWithURL = await firstValueFrom(pipe);
audio.src = progressWithURL.url;
audio.muted = false;
audio.volume = 1;
console.log('set audio src', progressWithURL.url);
})();
}, [mediaSet]);
// load video when MediaSet is loaded:
useEffect(() => {
(async function () {
if (mediaSet == null) {
return;
}
console.log('fetching video...');
const service = new MediaSetServiceClientImpl(newRPC());
const videoProgressStream = service.GetVideo({ id: mediaSet.id });
const pipe = videoProgressStream.pipe(
first((progress: GetVideoProgress) => progress.url != '')
);
const progressWithURL = await firstValueFrom(pipe);
video.src = progressWithURL.url;
console.log('set video src', progressWithURL.url);
})();
}, [mediaSet]);
// set viewport when MediaSet is loaded: // set viewport when MediaSet is loaded:
useEffect(() => { useEffect(() => {
if (mediaSet == null) { if (mediaSet == null) {

View File

@ -59,7 +59,7 @@ export const Waveform: React.FC<Props> = ({
); );
setPeaks(peaks); setPeaks(peaks);
})(); })();
}, [viewport]); }, [viewport, mediaSet]);
// convert position to canvas pixels // convert position to canvas pixels
useEffect(() => { useEffect(() => {

View File

@ -82,7 +82,9 @@ export interface Duration {
nanos: number; nanos: number;
} }
const baseDuration: object = { seconds: 0, nanos: 0 }; function createBaseDuration(): Duration {
return { seconds: 0, nanos: 0 };
}
export const Duration = { export const Duration = {
encode( encode(
@ -101,7 +103,7 @@ export const Duration = {
decode(input: _m0.Reader | Uint8Array, length?: number): Duration { decode(input: _m0.Reader | Uint8Array, length?: number): Duration {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseDuration } as Duration; const message = createBaseDuration();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -120,27 +122,22 @@ export const Duration = {
}, },
fromJSON(object: any): Duration { fromJSON(object: any): Duration {
const message = { ...baseDuration } as Duration; return {
message.seconds = seconds: isSet(object.seconds) ? Number(object.seconds) : 0,
object.seconds !== undefined && object.seconds !== null nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
? Number(object.seconds) };
: 0;
message.nanos =
object.nanos !== undefined && object.nanos !== null
? Number(object.nanos)
: 0;
return message;
}, },
toJSON(message: Duration): unknown { toJSON(message: Duration): unknown {
const obj: any = {}; const obj: any = {};
message.seconds !== undefined && (obj.seconds = message.seconds); message.seconds !== undefined &&
message.nanos !== undefined && (obj.nanos = message.nanos); (obj.seconds = Math.round(message.seconds));
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
return obj; return obj;
}, },
fromPartial<I extends Exact<DeepPartial<Duration>, I>>(object: I): Duration { fromPartial<I extends Exact<DeepPartial<Duration>, I>>(object: I): Duration {
const message = { ...baseDuration } as Duration; const message = createBaseDuration();
message.seconds = object.seconds ?? 0; message.seconds = object.seconds ?? 0;
message.nanos = object.nanos ?? 0; message.nanos = object.nanos ?? 0;
return message; return message;
@ -196,3 +193,7 @@ if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any; _m0.util.Long = Long as any;
_m0.configure(); _m0.configure();
} }
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}

View File

@ -71,6 +71,7 @@ export interface GetPeaksProgress {
peaks: number[]; peaks: number[];
percentComplete: number; percentComplete: number;
url: string; url: string;
audioFrames: number;
} }
export interface GetPeaksForSegmentRequest { export interface GetPeaksForSegmentRequest {
@ -115,7 +116,8 @@ export interface GetVideoThumbnailResponse {
height: number; height: number;
} }
const baseMediaSet: object = { function createBaseMediaSet(): MediaSet {
return {
id: "", id: "",
youtubeId: "", youtubeId: "",
title: "", title: "",
@ -127,9 +129,11 @@ const baseMediaSet: object = {
audioSampleRate: 0, audioSampleRate: 0,
audioYoutubeItag: 0, audioYoutubeItag: 0,
audioMimeType: "", audioMimeType: "",
videoDuration: undefined,
videoYoutubeItag: 0, videoYoutubeItag: 0,
videoMimeType: "", videoMimeType: "",
}; };
}
export const MediaSet = { export const MediaSet = {
encode( encode(
@ -184,7 +188,7 @@ export const MediaSet = {
decode(input: _m0.Reader | Uint8Array, length?: number): MediaSet { decode(input: _m0.Reader | Uint8Array, length?: number): MediaSet {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseMediaSet } as MediaSet; const message = createBaseMediaSet();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -239,63 +243,38 @@ export const MediaSet = {
}, },
fromJSON(object: any): MediaSet { fromJSON(object: any): MediaSet {
const message = { ...baseMediaSet } as MediaSet; return {
message.id = id: isSet(object.id) ? String(object.id) : "",
object.id !== undefined && object.id !== null ? String(object.id) : ""; youtubeId: isSet(object.youtubeId) ? String(object.youtubeId) : "",
message.youtubeId = title: isSet(object.title) ? String(object.title) : "",
object.youtubeId !== undefined && object.youtubeId !== null description: isSet(object.description) ? String(object.description) : "",
? String(object.youtubeId) author: isSet(object.author) ? String(object.author) : "",
: ""; audioChannels: isSet(object.audioChannels)
message.title =
object.title !== undefined && object.title !== null
? String(object.title)
: "";
message.description =
object.description !== undefined && object.description !== null
? String(object.description)
: "";
message.author =
object.author !== undefined && object.author !== null
? String(object.author)
: "";
message.audioChannels =
object.audioChannels !== undefined && object.audioChannels !== null
? Number(object.audioChannels) ? Number(object.audioChannels)
: 0; : 0,
message.audioApproxFrames = audioApproxFrames: isSet(object.audioApproxFrames)
object.audioApproxFrames !== undefined &&
object.audioApproxFrames !== null
? Number(object.audioApproxFrames) ? Number(object.audioApproxFrames)
: 0; : 0,
message.audioFrames = audioFrames: isSet(object.audioFrames) ? Number(object.audioFrames) : 0,
object.audioFrames !== undefined && object.audioFrames !== null audioSampleRate: isSet(object.audioSampleRate)
? Number(object.audioFrames)
: 0;
message.audioSampleRate =
object.audioSampleRate !== undefined && object.audioSampleRate !== null
? Number(object.audioSampleRate) ? Number(object.audioSampleRate)
: 0; : 0,
message.audioYoutubeItag = audioYoutubeItag: isSet(object.audioYoutubeItag)
object.audioYoutubeItag !== undefined && object.audioYoutubeItag !== null
? Number(object.audioYoutubeItag) ? Number(object.audioYoutubeItag)
: 0; : 0,
message.audioMimeType = audioMimeType: isSet(object.audioMimeType)
object.audioMimeType !== undefined && object.audioMimeType !== null
? String(object.audioMimeType) ? String(object.audioMimeType)
: ""; : "",
message.videoDuration = videoDuration: isSet(object.videoDuration)
object.videoDuration !== undefined && object.videoDuration !== null
? Duration.fromJSON(object.videoDuration) ? Duration.fromJSON(object.videoDuration)
: undefined; : undefined,
message.videoYoutubeItag = videoYoutubeItag: isSet(object.videoYoutubeItag)
object.videoYoutubeItag !== undefined && object.videoYoutubeItag !== null
? Number(object.videoYoutubeItag) ? Number(object.videoYoutubeItag)
: 0; : 0,
message.videoMimeType = videoMimeType: isSet(object.videoMimeType)
object.videoMimeType !== undefined && object.videoMimeType !== null
? String(object.videoMimeType) ? String(object.videoMimeType)
: ""; : "",
return message; };
}, },
toJSON(message: MediaSet): unknown { toJSON(message: MediaSet): unknown {
@ -307,15 +286,15 @@ export const MediaSet = {
(obj.description = message.description); (obj.description = message.description);
message.author !== undefined && (obj.author = message.author); message.author !== undefined && (obj.author = message.author);
message.audioChannels !== undefined && message.audioChannels !== undefined &&
(obj.audioChannels = message.audioChannels); (obj.audioChannels = Math.round(message.audioChannels));
message.audioApproxFrames !== undefined && message.audioApproxFrames !== undefined &&
(obj.audioApproxFrames = message.audioApproxFrames); (obj.audioApproxFrames = Math.round(message.audioApproxFrames));
message.audioFrames !== undefined && message.audioFrames !== undefined &&
(obj.audioFrames = message.audioFrames); (obj.audioFrames = Math.round(message.audioFrames));
message.audioSampleRate !== undefined && message.audioSampleRate !== undefined &&
(obj.audioSampleRate = message.audioSampleRate); (obj.audioSampleRate = Math.round(message.audioSampleRate));
message.audioYoutubeItag !== undefined && message.audioYoutubeItag !== undefined &&
(obj.audioYoutubeItag = message.audioYoutubeItag); (obj.audioYoutubeItag = Math.round(message.audioYoutubeItag));
message.audioMimeType !== undefined && message.audioMimeType !== undefined &&
(obj.audioMimeType = message.audioMimeType); (obj.audioMimeType = message.audioMimeType);
message.videoDuration !== undefined && message.videoDuration !== undefined &&
@ -323,14 +302,14 @@ export const MediaSet = {
? Duration.toJSON(message.videoDuration) ? Duration.toJSON(message.videoDuration)
: undefined); : undefined);
message.videoYoutubeItag !== undefined && message.videoYoutubeItag !== undefined &&
(obj.videoYoutubeItag = message.videoYoutubeItag); (obj.videoYoutubeItag = Math.round(message.videoYoutubeItag));
message.videoMimeType !== undefined && message.videoMimeType !== undefined &&
(obj.videoMimeType = message.videoMimeType); (obj.videoMimeType = message.videoMimeType);
return obj; return obj;
}, },
fromPartial<I extends Exact<DeepPartial<MediaSet>, I>>(object: I): MediaSet { fromPartial<I extends Exact<DeepPartial<MediaSet>, I>>(object: I): MediaSet {
const message = { ...baseMediaSet } as MediaSet; const message = createBaseMediaSet();
message.id = object.id ?? ""; message.id = object.id ?? "";
message.youtubeId = object.youtubeId ?? ""; message.youtubeId = object.youtubeId ?? "";
message.title = object.title ?? ""; message.title = object.title ?? "";
@ -352,7 +331,9 @@ export const MediaSet = {
}, },
}; };
const baseGetRequest: object = { youtubeId: "" }; function createBaseGetRequest(): GetRequest {
return { youtubeId: "" };
}
export const GetRequest = { export const GetRequest = {
encode( encode(
@ -368,7 +349,7 @@ export const GetRequest = {
decode(input: _m0.Reader | Uint8Array, length?: number): GetRequest { decode(input: _m0.Reader | Uint8Array, length?: number): GetRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseGetRequest } as GetRequest; const message = createBaseGetRequest();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -384,12 +365,9 @@ export const GetRequest = {
}, },
fromJSON(object: any): GetRequest { fromJSON(object: any): GetRequest {
const message = { ...baseGetRequest } as GetRequest; return {
message.youtubeId = youtubeId: isSet(object.youtubeId) ? String(object.youtubeId) : "",
object.youtubeId !== undefined && object.youtubeId !== null };
? String(object.youtubeId)
: "";
return message;
}, },
toJSON(message: GetRequest): unknown { toJSON(message: GetRequest): unknown {
@ -401,13 +379,15 @@ export const GetRequest = {
fromPartial<I extends Exact<DeepPartial<GetRequest>, I>>( fromPartial<I extends Exact<DeepPartial<GetRequest>, I>>(
object: I object: I
): GetRequest { ): GetRequest {
const message = { ...baseGetRequest } as GetRequest; const message = createBaseGetRequest();
message.youtubeId = object.youtubeId ?? ""; message.youtubeId = object.youtubeId ?? "";
return message; return message;
}, },
}; };
const baseGetPeaksRequest: object = { id: "", numBins: 0 }; function createBaseGetPeaksRequest(): GetPeaksRequest {
return { id: "", numBins: 0 };
}
export const GetPeaksRequest = { export const GetPeaksRequest = {
encode( encode(
@ -426,7 +406,7 @@ export const GetPeaksRequest = {
decode(input: _m0.Reader | Uint8Array, length?: number): GetPeaksRequest { decode(input: _m0.Reader | Uint8Array, length?: number): GetPeaksRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseGetPeaksRequest } as GetPeaksRequest; const message = createBaseGetPeaksRequest();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -445,34 +425,33 @@ export const GetPeaksRequest = {
}, },
fromJSON(object: any): GetPeaksRequest { fromJSON(object: any): GetPeaksRequest {
const message = { ...baseGetPeaksRequest } as GetPeaksRequest; return {
message.id = id: isSet(object.id) ? String(object.id) : "",
object.id !== undefined && object.id !== null ? String(object.id) : ""; numBins: isSet(object.numBins) ? Number(object.numBins) : 0,
message.numBins = };
object.numBins !== undefined && object.numBins !== null
? Number(object.numBins)
: 0;
return message;
}, },
toJSON(message: GetPeaksRequest): unknown { toJSON(message: GetPeaksRequest): unknown {
const obj: any = {}; const obj: any = {};
message.id !== undefined && (obj.id = message.id); message.id !== undefined && (obj.id = message.id);
message.numBins !== undefined && (obj.numBins = message.numBins); message.numBins !== undefined &&
(obj.numBins = Math.round(message.numBins));
return obj; return obj;
}, },
fromPartial<I extends Exact<DeepPartial<GetPeaksRequest>, I>>( fromPartial<I extends Exact<DeepPartial<GetPeaksRequest>, I>>(
object: I object: I
): GetPeaksRequest { ): GetPeaksRequest {
const message = { ...baseGetPeaksRequest } as GetPeaksRequest; const message = createBaseGetPeaksRequest();
message.id = object.id ?? ""; message.id = object.id ?? "";
message.numBins = object.numBins ?? 0; message.numBins = object.numBins ?? 0;
return message; return message;
}, },
}; };
const baseGetPeaksProgress: object = { peaks: 0, percentComplete: 0, url: "" }; function createBaseGetPeaksProgress(): GetPeaksProgress {
return { peaks: [], percentComplete: 0, url: "", audioFrames: 0 };
}
export const GetPeaksProgress = { export const GetPeaksProgress = {
encode( encode(
@ -490,14 +469,16 @@ export const GetPeaksProgress = {
if (message.url !== "") { if (message.url !== "") {
writer.uint32(26).string(message.url); writer.uint32(26).string(message.url);
} }
if (message.audioFrames !== 0) {
writer.uint32(32).int64(message.audioFrames);
}
return writer; return writer;
}, },
decode(input: _m0.Reader | Uint8Array, length?: number): GetPeaksProgress { decode(input: _m0.Reader | Uint8Array, length?: number): GetPeaksProgress {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseGetPeaksProgress } as GetPeaksProgress; const message = createBaseGetPeaksProgress();
message.peaks = [];
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -517,6 +498,9 @@ export const GetPeaksProgress = {
case 3: case 3:
message.url = reader.string(); message.url = reader.string();
break; break;
case 4:
message.audioFrames = longToNumber(reader.int64() as Long);
break;
default: default:
reader.skipType(tag & 7); reader.skipType(tag & 7);
break; break;
@ -526,47 +510,48 @@ export const GetPeaksProgress = {
}, },
fromJSON(object: any): GetPeaksProgress { fromJSON(object: any): GetPeaksProgress {
const message = { ...baseGetPeaksProgress } as GetPeaksProgress; return {
message.peaks = (object.peaks ?? []).map((e: any) => Number(e)); peaks: Array.isArray(object?.peaks)
message.percentComplete = ? object.peaks.map((e: any) => Number(e))
object.percentComplete !== undefined && object.percentComplete !== null : [],
percentComplete: isSet(object.percentComplete)
? Number(object.percentComplete) ? Number(object.percentComplete)
: 0; : 0,
message.url = url: isSet(object.url) ? String(object.url) : "",
object.url !== undefined && object.url !== null ? String(object.url) : ""; audioFrames: isSet(object.audioFrames) ? Number(object.audioFrames) : 0,
return message; };
}, },
toJSON(message: GetPeaksProgress): unknown { toJSON(message: GetPeaksProgress): unknown {
const obj: any = {}; const obj: any = {};
if (message.peaks) { if (message.peaks) {
obj.peaks = message.peaks.map((e) => e); obj.peaks = message.peaks.map((e) => Math.round(e));
} else { } else {
obj.peaks = []; obj.peaks = [];
} }
message.percentComplete !== undefined && message.percentComplete !== undefined &&
(obj.percentComplete = message.percentComplete); (obj.percentComplete = message.percentComplete);
message.url !== undefined && (obj.url = message.url); message.url !== undefined && (obj.url = message.url);
message.audioFrames !== undefined &&
(obj.audioFrames = Math.round(message.audioFrames));
return obj; return obj;
}, },
fromPartial<I extends Exact<DeepPartial<GetPeaksProgress>, I>>( fromPartial<I extends Exact<DeepPartial<GetPeaksProgress>, I>>(
object: I object: I
): GetPeaksProgress { ): GetPeaksProgress {
const message = { ...baseGetPeaksProgress } as GetPeaksProgress; const message = createBaseGetPeaksProgress();
message.peaks = object.peaks?.map((e) => e) || []; message.peaks = object.peaks?.map((e) => e) || [];
message.percentComplete = object.percentComplete ?? 0; message.percentComplete = object.percentComplete ?? 0;
message.url = object.url ?? ""; message.url = object.url ?? "";
message.audioFrames = object.audioFrames ?? 0;
return message; return message;
}, },
}; };
const baseGetPeaksForSegmentRequest: object = { function createBaseGetPeaksForSegmentRequest(): GetPeaksForSegmentRequest {
id: "", return { id: "", numBins: 0, startFrame: 0, endFrame: 0 };
numBins: 0, }
startFrame: 0,
endFrame: 0,
};
export const GetPeaksForSegmentRequest = { export const GetPeaksForSegmentRequest = {
encode( encode(
@ -594,9 +579,7 @@ export const GetPeaksForSegmentRequest = {
): GetPeaksForSegmentRequest { ): GetPeaksForSegmentRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { const message = createBaseGetPeaksForSegmentRequest();
...baseGetPeaksForSegmentRequest,
} as GetPeaksForSegmentRequest;
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -621,41 +604,30 @@ export const GetPeaksForSegmentRequest = {
}, },
fromJSON(object: any): GetPeaksForSegmentRequest { fromJSON(object: any): GetPeaksForSegmentRequest {
const message = { return {
...baseGetPeaksForSegmentRequest, id: isSet(object.id) ? String(object.id) : "",
} as GetPeaksForSegmentRequest; numBins: isSet(object.numBins) ? Number(object.numBins) : 0,
message.id = startFrame: isSet(object.startFrame) ? Number(object.startFrame) : 0,
object.id !== undefined && object.id !== null ? String(object.id) : ""; endFrame: isSet(object.endFrame) ? Number(object.endFrame) : 0,
message.numBins = };
object.numBins !== undefined && object.numBins !== null
? Number(object.numBins)
: 0;
message.startFrame =
object.startFrame !== undefined && object.startFrame !== null
? Number(object.startFrame)
: 0;
message.endFrame =
object.endFrame !== undefined && object.endFrame !== null
? Number(object.endFrame)
: 0;
return message;
}, },
toJSON(message: GetPeaksForSegmentRequest): unknown { toJSON(message: GetPeaksForSegmentRequest): unknown {
const obj: any = {}; const obj: any = {};
message.id !== undefined && (obj.id = message.id); message.id !== undefined && (obj.id = message.id);
message.numBins !== undefined && (obj.numBins = message.numBins); message.numBins !== undefined &&
message.startFrame !== undefined && (obj.startFrame = message.startFrame); (obj.numBins = Math.round(message.numBins));
message.endFrame !== undefined && (obj.endFrame = message.endFrame); message.startFrame !== undefined &&
(obj.startFrame = Math.round(message.startFrame));
message.endFrame !== undefined &&
(obj.endFrame = Math.round(message.endFrame));
return obj; return obj;
}, },
fromPartial<I extends Exact<DeepPartial<GetPeaksForSegmentRequest>, I>>( fromPartial<I extends Exact<DeepPartial<GetPeaksForSegmentRequest>, I>>(
object: I object: I
): GetPeaksForSegmentRequest { ): GetPeaksForSegmentRequest {
const message = { const message = createBaseGetPeaksForSegmentRequest();
...baseGetPeaksForSegmentRequest,
} as GetPeaksForSegmentRequest;
message.id = object.id ?? ""; message.id = object.id ?? "";
message.numBins = object.numBins ?? 0; message.numBins = object.numBins ?? 0;
message.startFrame = object.startFrame ?? 0; message.startFrame = object.startFrame ?? 0;
@ -664,7 +636,9 @@ export const GetPeaksForSegmentRequest = {
}, },
}; };
const baseGetPeaksForSegmentResponse: object = { peaks: 0 }; function createBaseGetPeaksForSegmentResponse(): GetPeaksForSegmentResponse {
return { peaks: [] };
}
export const GetPeaksForSegmentResponse = { export const GetPeaksForSegmentResponse = {
encode( encode(
@ -685,10 +659,7 @@ export const GetPeaksForSegmentResponse = {
): GetPeaksForSegmentResponse { ): GetPeaksForSegmentResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { const message = createBaseGetPeaksForSegmentResponse();
...baseGetPeaksForSegmentResponse,
} as GetPeaksForSegmentResponse;
message.peaks = [];
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -711,17 +682,17 @@ export const GetPeaksForSegmentResponse = {
}, },
fromJSON(object: any): GetPeaksForSegmentResponse { fromJSON(object: any): GetPeaksForSegmentResponse {
const message = { return {
...baseGetPeaksForSegmentResponse, peaks: Array.isArray(object?.peaks)
} as GetPeaksForSegmentResponse; ? object.peaks.map((e: any) => Number(e))
message.peaks = (object.peaks ?? []).map((e: any) => Number(e)); : [],
return message; };
}, },
toJSON(message: GetPeaksForSegmentResponse): unknown { toJSON(message: GetPeaksForSegmentResponse): unknown {
const obj: any = {}; const obj: any = {};
if (message.peaks) { if (message.peaks) {
obj.peaks = message.peaks.map((e) => e); obj.peaks = message.peaks.map((e) => Math.round(e));
} else { } else {
obj.peaks = []; obj.peaks = [];
} }
@ -731,20 +702,15 @@ export const GetPeaksForSegmentResponse = {
fromPartial<I extends Exact<DeepPartial<GetPeaksForSegmentResponse>, I>>( fromPartial<I extends Exact<DeepPartial<GetPeaksForSegmentResponse>, I>>(
object: I object: I
): GetPeaksForSegmentResponse { ): GetPeaksForSegmentResponse {
const message = { const message = createBaseGetPeaksForSegmentResponse();
...baseGetPeaksForSegmentResponse,
} as GetPeaksForSegmentResponse;
message.peaks = object.peaks?.map((e) => e) || []; message.peaks = object.peaks?.map((e) => e) || [];
return message; return message;
}, },
}; };
const baseGetAudioSegmentRequest: object = { function createBaseGetAudioSegmentRequest(): GetAudioSegmentRequest {
id: "", return { id: "", startFrame: 0, endFrame: 0, format: 0 };
startFrame: 0, }
endFrame: 0,
format: 0,
};
export const GetAudioSegmentRequest = { export const GetAudioSegmentRequest = {
encode( encode(
@ -772,7 +738,7 @@ export const GetAudioSegmentRequest = {
): GetAudioSegmentRequest { ): GetAudioSegmentRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseGetAudioSegmentRequest } as GetAudioSegmentRequest; const message = createBaseGetAudioSegmentRequest();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -797,29 +763,21 @@ export const GetAudioSegmentRequest = {
}, },
fromJSON(object: any): GetAudioSegmentRequest { fromJSON(object: any): GetAudioSegmentRequest {
const message = { ...baseGetAudioSegmentRequest } as GetAudioSegmentRequest; return {
message.id = id: isSet(object.id) ? String(object.id) : "",
object.id !== undefined && object.id !== null ? String(object.id) : ""; startFrame: isSet(object.startFrame) ? Number(object.startFrame) : 0,
message.startFrame = endFrame: isSet(object.endFrame) ? Number(object.endFrame) : 0,
object.startFrame !== undefined && object.startFrame !== null format: isSet(object.format) ? audioFormatFromJSON(object.format) : 0,
? Number(object.startFrame) };
: 0;
message.endFrame =
object.endFrame !== undefined && object.endFrame !== null
? Number(object.endFrame)
: 0;
message.format =
object.format !== undefined && object.format !== null
? audioFormatFromJSON(object.format)
: 0;
return message;
}, },
toJSON(message: GetAudioSegmentRequest): unknown { toJSON(message: GetAudioSegmentRequest): unknown {
const obj: any = {}; const obj: any = {};
message.id !== undefined && (obj.id = message.id); message.id !== undefined && (obj.id = message.id);
message.startFrame !== undefined && (obj.startFrame = message.startFrame); message.startFrame !== undefined &&
message.endFrame !== undefined && (obj.endFrame = message.endFrame); (obj.startFrame = Math.round(message.startFrame));
message.endFrame !== undefined &&
(obj.endFrame = Math.round(message.endFrame));
message.format !== undefined && message.format !== undefined &&
(obj.format = audioFormatToJSON(message.format)); (obj.format = audioFormatToJSON(message.format));
return obj; return obj;
@ -828,7 +786,7 @@ export const GetAudioSegmentRequest = {
fromPartial<I extends Exact<DeepPartial<GetAudioSegmentRequest>, I>>( fromPartial<I extends Exact<DeepPartial<GetAudioSegmentRequest>, I>>(
object: I object: I
): GetAudioSegmentRequest { ): GetAudioSegmentRequest {
const message = { ...baseGetAudioSegmentRequest } as GetAudioSegmentRequest; const message = createBaseGetAudioSegmentRequest();
message.id = object.id ?? ""; message.id = object.id ?? "";
message.startFrame = object.startFrame ?? 0; message.startFrame = object.startFrame ?? 0;
message.endFrame = object.endFrame ?? 0; message.endFrame = object.endFrame ?? 0;
@ -837,7 +795,9 @@ export const GetAudioSegmentRequest = {
}, },
}; };
const baseGetAudioSegmentProgress: object = { percentComplete: 0 }; function createBaseGetAudioSegmentProgress(): GetAudioSegmentProgress {
return { percentComplete: 0, audioData: new Uint8Array() };
}
export const GetAudioSegmentProgress = { export const GetAudioSegmentProgress = {
encode( encode(
@ -859,10 +819,7 @@ export const GetAudioSegmentProgress = {
): GetAudioSegmentProgress { ): GetAudioSegmentProgress {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { const message = createBaseGetAudioSegmentProgress();
...baseGetAudioSegmentProgress,
} as GetAudioSegmentProgress;
message.audioData = new Uint8Array();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -881,18 +838,14 @@ export const GetAudioSegmentProgress = {
}, },
fromJSON(object: any): GetAudioSegmentProgress { fromJSON(object: any): GetAudioSegmentProgress {
const message = { return {
...baseGetAudioSegmentProgress, percentComplete: isSet(object.percentComplete)
} as GetAudioSegmentProgress;
message.percentComplete =
object.percentComplete !== undefined && object.percentComplete !== null
? Number(object.percentComplete) ? Number(object.percentComplete)
: 0; : 0,
message.audioData = audioData: isSet(object.audioData)
object.audioData !== undefined && object.audioData !== null
? bytesFromBase64(object.audioData) ? bytesFromBase64(object.audioData)
: new Uint8Array(); : new Uint8Array(),
return message; };
}, },
toJSON(message: GetAudioSegmentProgress): unknown { toJSON(message: GetAudioSegmentProgress): unknown {
@ -909,16 +862,16 @@ export const GetAudioSegmentProgress = {
fromPartial<I extends Exact<DeepPartial<GetAudioSegmentProgress>, I>>( fromPartial<I extends Exact<DeepPartial<GetAudioSegmentProgress>, I>>(
object: I object: I
): GetAudioSegmentProgress { ): GetAudioSegmentProgress {
const message = { const message = createBaseGetAudioSegmentProgress();
...baseGetAudioSegmentProgress,
} as GetAudioSegmentProgress;
message.percentComplete = object.percentComplete ?? 0; message.percentComplete = object.percentComplete ?? 0;
message.audioData = object.audioData ?? new Uint8Array(); message.audioData = object.audioData ?? new Uint8Array();
return message; return message;
}, },
}; };
const baseGetVideoRequest: object = { id: "" }; function createBaseGetVideoRequest(): GetVideoRequest {
return { id: "" };
}
export const GetVideoRequest = { export const GetVideoRequest = {
encode( encode(
@ -934,7 +887,7 @@ export const GetVideoRequest = {
decode(input: _m0.Reader | Uint8Array, length?: number): GetVideoRequest { decode(input: _m0.Reader | Uint8Array, length?: number): GetVideoRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseGetVideoRequest } as GetVideoRequest; const message = createBaseGetVideoRequest();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -950,10 +903,9 @@ export const GetVideoRequest = {
}, },
fromJSON(object: any): GetVideoRequest { fromJSON(object: any): GetVideoRequest {
const message = { ...baseGetVideoRequest } as GetVideoRequest; return {
message.id = id: isSet(object.id) ? String(object.id) : "",
object.id !== undefined && object.id !== null ? String(object.id) : ""; };
return message;
}, },
toJSON(message: GetVideoRequest): unknown { toJSON(message: GetVideoRequest): unknown {
@ -965,13 +917,15 @@ export const GetVideoRequest = {
fromPartial<I extends Exact<DeepPartial<GetVideoRequest>, I>>( fromPartial<I extends Exact<DeepPartial<GetVideoRequest>, I>>(
object: I object: I
): GetVideoRequest { ): GetVideoRequest {
const message = { ...baseGetVideoRequest } as GetVideoRequest; const message = createBaseGetVideoRequest();
message.id = object.id ?? ""; message.id = object.id ?? "";
return message; return message;
}, },
}; };
const baseGetVideoProgress: object = { percentComplete: 0, url: "" }; function createBaseGetVideoProgress(): GetVideoProgress {
return { percentComplete: 0, url: "" };
}
export const GetVideoProgress = { export const GetVideoProgress = {
encode( encode(
@ -990,7 +944,7 @@ export const GetVideoProgress = {
decode(input: _m0.Reader | Uint8Array, length?: number): GetVideoProgress { decode(input: _m0.Reader | Uint8Array, length?: number): GetVideoProgress {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseGetVideoProgress } as GetVideoProgress; const message = createBaseGetVideoProgress();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -1009,14 +963,12 @@ export const GetVideoProgress = {
}, },
fromJSON(object: any): GetVideoProgress { fromJSON(object: any): GetVideoProgress {
const message = { ...baseGetVideoProgress } as GetVideoProgress; return {
message.percentComplete = percentComplete: isSet(object.percentComplete)
object.percentComplete !== undefined && object.percentComplete !== null
? Number(object.percentComplete) ? Number(object.percentComplete)
: 0; : 0,
message.url = url: isSet(object.url) ? String(object.url) : "",
object.url !== undefined && object.url !== null ? String(object.url) : ""; };
return message;
}, },
toJSON(message: GetVideoProgress): unknown { toJSON(message: GetVideoProgress): unknown {
@ -1030,14 +982,16 @@ export const GetVideoProgress = {
fromPartial<I extends Exact<DeepPartial<GetVideoProgress>, I>>( fromPartial<I extends Exact<DeepPartial<GetVideoProgress>, I>>(
object: I object: I
): GetVideoProgress { ): GetVideoProgress {
const message = { ...baseGetVideoProgress } as GetVideoProgress; const message = createBaseGetVideoProgress();
message.percentComplete = object.percentComplete ?? 0; message.percentComplete = object.percentComplete ?? 0;
message.url = object.url ?? ""; message.url = object.url ?? "";
return message; return message;
}, },
}; };
const baseGetVideoThumbnailRequest: object = { id: "" }; function createBaseGetVideoThumbnailRequest(): GetVideoThumbnailRequest {
return { id: "" };
}
export const GetVideoThumbnailRequest = { export const GetVideoThumbnailRequest = {
encode( encode(
@ -1056,9 +1010,7 @@ export const GetVideoThumbnailRequest = {
): GetVideoThumbnailRequest { ): GetVideoThumbnailRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { const message = createBaseGetVideoThumbnailRequest();
...baseGetVideoThumbnailRequest,
} as GetVideoThumbnailRequest;
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -1074,12 +1026,9 @@ export const GetVideoThumbnailRequest = {
}, },
fromJSON(object: any): GetVideoThumbnailRequest { fromJSON(object: any): GetVideoThumbnailRequest {
const message = { return {
...baseGetVideoThumbnailRequest, id: isSet(object.id) ? String(object.id) : "",
} as GetVideoThumbnailRequest; };
message.id =
object.id !== undefined && object.id !== null ? String(object.id) : "";
return message;
}, },
toJSON(message: GetVideoThumbnailRequest): unknown { toJSON(message: GetVideoThumbnailRequest): unknown {
@ -1091,15 +1040,15 @@ export const GetVideoThumbnailRequest = {
fromPartial<I extends Exact<DeepPartial<GetVideoThumbnailRequest>, I>>( fromPartial<I extends Exact<DeepPartial<GetVideoThumbnailRequest>, I>>(
object: I object: I
): GetVideoThumbnailRequest { ): GetVideoThumbnailRequest {
const message = { const message = createBaseGetVideoThumbnailRequest();
...baseGetVideoThumbnailRequest,
} as GetVideoThumbnailRequest;
message.id = object.id ?? ""; message.id = object.id ?? "";
return message; return message;
}, },
}; };
const baseGetVideoThumbnailResponse: object = { width: 0, height: 0 }; function createBaseGetVideoThumbnailResponse(): GetVideoThumbnailResponse {
return { image: new Uint8Array(), width: 0, height: 0 };
}
export const GetVideoThumbnailResponse = { export const GetVideoThumbnailResponse = {
encode( encode(
@ -1124,10 +1073,7 @@ export const GetVideoThumbnailResponse = {
): GetVideoThumbnailResponse { ): GetVideoThumbnailResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = { const message = createBaseGetVideoThumbnailResponse();
...baseGetVideoThumbnailResponse,
} as GetVideoThumbnailResponse;
message.image = new Uint8Array();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@ -1149,22 +1095,13 @@ export const GetVideoThumbnailResponse = {
}, },
fromJSON(object: any): GetVideoThumbnailResponse { fromJSON(object: any): GetVideoThumbnailResponse {
const message = { return {
...baseGetVideoThumbnailResponse, image: isSet(object.image)
} as GetVideoThumbnailResponse;
message.image =
object.image !== undefined && object.image !== null
? bytesFromBase64(object.image) ? bytesFromBase64(object.image)
: new Uint8Array(); : new Uint8Array(),
message.width = width: isSet(object.width) ? Number(object.width) : 0,
object.width !== undefined && object.width !== null height: isSet(object.height) ? Number(object.height) : 0,
? Number(object.width) };
: 0;
message.height =
object.height !== undefined && object.height !== null
? Number(object.height)
: 0;
return message;
}, },
toJSON(message: GetVideoThumbnailResponse): unknown { toJSON(message: GetVideoThumbnailResponse): unknown {
@ -1173,17 +1110,15 @@ export const GetVideoThumbnailResponse = {
(obj.image = base64FromBytes( (obj.image = base64FromBytes(
message.image !== undefined ? message.image : new Uint8Array() message.image !== undefined ? message.image : new Uint8Array()
)); ));
message.width !== undefined && (obj.width = message.width); message.width !== undefined && (obj.width = Math.round(message.width));
message.height !== undefined && (obj.height = message.height); message.height !== undefined && (obj.height = Math.round(message.height));
return obj; return obj;
}, },
fromPartial<I extends Exact<DeepPartial<GetVideoThumbnailResponse>, I>>( fromPartial<I extends Exact<DeepPartial<GetVideoThumbnailResponse>, I>>(
object: I object: I
): GetVideoThumbnailResponse { ): GetVideoThumbnailResponse {
const message = { const message = createBaseGetVideoThumbnailResponse();
...baseGetVideoThumbnailResponse,
} as GetVideoThumbnailResponse;
message.image = object.image ?? new Uint8Array(); message.image = object.image ?? new Uint8Array();
message.width = object.width ?? 0; message.width = object.width ?? 0;
message.height = object.height ?? 0; message.height = object.height ?? 0;
@ -1625,3 +1560,7 @@ if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any; _m0.util.Long = Long as any;
_m0.configure(); _m0.configure();
} }
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}

View File

@ -1160,7 +1160,8 @@ proto.media_set.GetPeaksProgress.toObject = function(includeInstance, msg) {
var f, obj = { var f, obj = {
peaksList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f, peaksList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f,
percentComplete: jspb.Message.getFloatingPointFieldWithDefault(msg, 2, 0.0), percentComplete: jspb.Message.getFloatingPointFieldWithDefault(msg, 2, 0.0),
url: jspb.Message.getFieldWithDefault(msg, 3, "") url: jspb.Message.getFieldWithDefault(msg, 3, ""),
audioFrames: jspb.Message.getFieldWithDefault(msg, 4, 0)
}; };
if (includeInstance) { if (includeInstance) {
@ -1211,6 +1212,10 @@ proto.media_set.GetPeaksProgress.deserializeBinaryFromReader = function(msg, rea
var value = /** @type {string} */ (reader.readString()); var value = /** @type {string} */ (reader.readString());
msg.setUrl(value); msg.setUrl(value);
break; break;
case 4:
var value = /** @type {number} */ (reader.readInt64());
msg.setAudioFrames(value);
break;
default: default:
reader.skipField(); reader.skipField();
break; break;
@ -1261,6 +1266,13 @@ proto.media_set.GetPeaksProgress.serializeBinaryToWriter = function(message, wri
f f
); );
} }
f = message.getAudioFrames();
if (f !== 0) {
writer.writeInt64(
4,
f
);
}
}; };
@ -1337,6 +1349,24 @@ proto.media_set.GetPeaksProgress.prototype.setUrl = function(value) {
}; };
/**
* optional int64 audio_frames = 4;
* @return {number}
*/
proto.media_set.GetPeaksProgress.prototype.getAudioFrames = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0));
};
/**
* @param {number} value
* @return {!proto.media_set.GetPeaksProgress} returns this
*/
proto.media_set.GetPeaksProgress.prototype.setAudioFrames = function(value) {
return jspb.Message.setProto3IntField(this, 4, value);
};

View File

@ -39,6 +39,7 @@ message GetPeaksProgress {
repeated int32 peaks = 1; repeated int32 peaks = 1;
float percent_complete = 2; float percent_complete = 2;
string url = 3; string url = 3;
int64 audio_frames = 4;
} }
message GetPeaksForSegmentRequest { message GetPeaksForSegmentRequest {