Skip to content

Commit

Permalink
Feat: update and use proto model
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Oct 15, 2023
1 parent 9e95248 commit ae7450b
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 269 deletions.
2 changes: 1 addition & 1 deletion proto.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=browser,esModuleInterop=true,useOptionals=messages --ts_proto_out=. ./src/proto/*.proto
protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=browser,esModuleInterop=true,useOptionals=none --ts_proto_out=. ./src/proto/*.proto
59 changes: 35 additions & 24 deletions src/plugins/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ export const sync = (cbk: callback): resould => {
let player: Artplayer | undefined = undefined;
const publishSeek = useDebounceFn((currentTime: number) => {
if (!player || player.option.isLive) return;
cbk["publishStatus"]({
type: ElementMessageType.CHANGE_SEEK,
seek: currentTime,
rate: player.playbackRate
});
cbk["publishStatus"](
ElementMessage.create({
type: ElementMessageType.CHANGE_SEEK,
seek: currentTime,
rate: player.playbackRate
})
);
devLog("视频空降,:", player.currentTime);
}, debounceTime);

Expand All @@ -40,11 +42,13 @@ export const sync = (cbk: callback): resould => {

const publishPlay = () => {
if (!player || player.option.isLive) return;
cbk["publishStatus"]({
type: ElementMessageType.PLAY,
seek: player.currentTime,
rate: player.playbackRate
});
cbk["publishStatus"](
ElementMessage.create({
type: ElementMessageType.PLAY,
seek: player.currentTime,
rate: player.playbackRate
})
);
};

const publishPlayDebounce = debounce(publishPlay);
Expand All @@ -68,11 +72,13 @@ export const sync = (cbk: callback): resould => {

const publishPause = () => {
if (!player || player.option.isLive) return;
cbk["publishStatus"]({
type: ElementMessageType.PAUSE,
seek: player.currentTime,
rate: player.playbackRate
});
cbk["publishStatus"](
ElementMessage.create({
type: ElementMessageType.PAUSE,
seek: player.currentTime,
rate: player.playbackRate
})
);
};

const publishPauseDebounce = debounce(publishPause);
Expand All @@ -88,11 +94,13 @@ export const sync = (cbk: callback): resould => {

const publishRate = () => {
if (!player || player.option.isLive) return;
cbk["publishStatus"]({
type: ElementMessageType.CHANGE_RATE,
seek: player.currentTime,
rate: player.playbackRate
});
cbk["publishStatus"](
ElementMessage.create({
type: ElementMessageType.CHANGE_RATE,
seek: player.currentTime,
rate: player.playbackRate
})
);
devLog("视频倍速,seek:", player.currentTime);
};

Expand Down Expand Up @@ -122,10 +130,13 @@ export const sync = (cbk: callback): resould => {

intervals.push(
setInterval(() => {
cbk["publishStatus"]({
type: ElementMessageType.CHECK_SEEK,
seek: art.currentTime
});
cbk["publishStatus"](
ElementMessage.create({
type: ElementMessageType.CHECK_SEEK,
seek: art.currentTime,
rate: art.playbackRate
})
);
}, 5000)
);
});
Expand Down
26 changes: 15 additions & 11 deletions src/proto/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ enum ElementMessageType {
CHANGE_PEOPLE = 12;
}

message BaseMovieInfo {
string url = 1;
string name = 2;
bool live = 3;
bool proxy = 4;
bool rtmpSource = 5;
string type = 6;
map<string, string> headers = 7;
}

message MovieInfo {
uint64 id = 1;
string url = 2;
string name = 3;
bool live = 4;
bool proxy = 5;
bool rtmp_source = 6;
string type = 7;
map<string, string> headers = 8;
string pull_key = 9;
int64 created_at = 10;
string creator = 11;
BaseMovieInfo base = 2;
string pullKey = 3;
int64 createdAt = 4;
string creator = 5;
}

message Status {
Expand All @@ -51,6 +55,6 @@ message ElementMessage {
double rate = 4;
double seek = 5;
optional Current current = 6;
int64 people_num = 7;
int64 peopleNum = 7;
int64 time = 8;
}
Loading

0 comments on commit ae7450b

Please sign in to comment.