vtt subtitles
This commit is contained in:
@@ -6,6 +6,7 @@ const spacetimedb = schema({
|
||||
{
|
||||
id: t.u64().primaryKey(),
|
||||
url: t.string(),
|
||||
subtitleUrl: t.string(),
|
||||
timePosition: t.f64(),
|
||||
isPlaying: t.bool(),
|
||||
lastUpdatedAt: t.timestamp(),
|
||||
@@ -19,6 +20,7 @@ export const init = spacetimedb.init((ctx) => {
|
||||
ctx.db.videoState.insert({
|
||||
id: 1n,
|
||||
url: "https://cdn.cazzzer.com/LycoReco08.mkv",
|
||||
subtitleUrl: "",
|
||||
timePosition: 0.0,
|
||||
isPlaying: false,
|
||||
lastUpdatedAt: ctx.timestamp,
|
||||
@@ -34,6 +36,7 @@ export const set_url = spacetimedb.reducer({ url: t.string() }, (ctx, { url }) =
|
||||
ctx.db.videoState.id.update({
|
||||
...row,
|
||||
url,
|
||||
subtitleUrl: "", // Clear subtitle on new video
|
||||
timePosition: 0.0,
|
||||
isPlaying: false,
|
||||
lastUpdatedAt: ctx.timestamp,
|
||||
@@ -71,3 +74,13 @@ export const seek = spacetimedb.reducer({ time_position: t.f64() }, (ctx, { time
|
||||
lastUpdatedAt: ctx.timestamp,
|
||||
});
|
||||
});
|
||||
|
||||
export const set_subtitle_url = spacetimedb.reducer({ url: t.string() }, (ctx, { url }) => {
|
||||
const row = ctx.db.videoState.id.find(1n);
|
||||
if (!row) return;
|
||||
ctx.db.videoState.id.update({
|
||||
...row,
|
||||
subtitleUrl: url,
|
||||
lastUpdatedAt: ctx.timestamp,
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user