Skip to content

Commit c2dd025

Browse files
committed
I'm crushing your head!
1 parent 4d7f7eb commit c2dd025

2 files changed

Lines changed: 90 additions & 24 deletions

File tree

apps/media/VideoCutter.js

Lines changed: 89 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
/*9/9/25: 3 ways of referencing the time points in a video timeline:
1+
/*9/9/25: «
2+
3+
@FSKROTKL: Uncomment those 2 lines so that when scrolling the timeline, the main video
4+
will seek to the first time showing on the ruler, and the marker will be set there.
5+
6+
Otherwise, the current time marker will not always be visible, but when starting to
7+
play the video , we MAY want to seek to it.
8+
9+
@PXJKFMG: I don't know if this actually ever really DID anything!?!?
10+
11+
12+
3 ways of referencing the time points in a video timeline
213
314
1) floating point: this is the literal time value (no mark created)
415
2) decimal: this is the mark's number in an array of anonymous marks
516
3) symbolic: currently, only single (1 byte) alphabetic characters: a-zA-Z
617
7-
The main question is whether the named marks are only in a hash map or are also in
18+
@AQUEORK, I am trying to remove the await part that causes the delay factor when
19+
seeking to the end of the timeline. I just want to be able to hurry up and draw
20+
the ruler without having to wait for the video seek operation to finish.
821
9-
*/
22+
We are only calling await_seek() ONCE now, when doing reencode() inside of
23+
render_from_slices(). It is NECESSARY that we wait for the video to seek to the
24+
given frame (decode it so the image shows up in the video element) so that the
25+
call to createImageBitmap(vid) actually works.
26+
27+
»*/
1028
/*9/7/25: Need to seriously simplyfy the timeline positioning/rendering logic. Right now, «
1129
there is an issue for when the timeline is wider than the window, and the time marker is at
1230
the end. It seems that the timeline is positioned so that only a couple preview frames are
@@ -413,7 +431,7 @@ const load_webm=async()=>{//«
413431
file_bytes = await node.bytes;
414432
get_clusters();
415433
};//»
416-
434+
///*
417435
const await_seek = (tm)=>{//«
418436
return new Promise((Y,N)=>{
419437
vid.onseeked = ()=>{
@@ -423,6 +441,11 @@ const await_seek = (tm)=>{//«
423441
tmdiv.innerHTML = get_main_time_str(tm);
424442
});
425443
};//»
444+
//*/
445+
const set_curtime = tm => {
446+
vid.currentTime = tm;
447+
tmdiv.innerHTML = get_main_time_str(tm);
448+
};
426449

427450
const handle_tab = k => {//«
428451

@@ -485,7 +508,8 @@ const try_delete = async()=>{//«
485508
if (cur_mark){
486509
is_waiting = true;
487510
// await cur_mark._on();
488-
await seek_to_time(cur_mark._time);
511+
// await seek_to_time(cur_mark._time);
512+
seek_to_time(cur_mark._time);
489513
let use_id = cur_mark._id;
490514
if (isNum(use_id)) use_id++;
491515
if (await wdg.popyesno(`Delete marker: '${use_id}'?`)){
@@ -1039,7 +1063,10 @@ This is either called by scroll_time_marker or by handle_arrow.
10391063
if (which == "LEFT") dir=1;
10401064
else dir = -1;
10411065
let inc;
1042-
if (opts.small){
1066+
if (opts.delta){
1067+
inc = dir*opts.delta;
1068+
}
1069+
else if (opts.small){
10431070
inc = dir*GRID_W;
10441071
}
10451072
else{
@@ -1050,8 +1077,9 @@ This is either called by scroll_time_marker or by handle_arrow.
10501077
let diff = Main._w - ((viddur+(gotx/mag_pix_per_sec)) * mag_pix_per_sec);
10511078
let did_adjust = false;
10521079
if(diff > 0){
1053-
did_adjust = true;
1054-
gotx+=diff;
1080+
//log("DID ADJUST", diff);
1081+
// did_adjust = true;
1082+
// gotx+=diff;
10551083
}
10561084
timeline._xLoc = gotx;
10571085
let tr = get_timeline_rect();
@@ -1063,8 +1091,11 @@ This is either called by scroll_time_marker or by handle_arrow.
10631091
}
10641092

10651093
align_timeline(did_adjust);
1066-
let xdiff = tm_x - timeline._xLoc;
1067-
mark._xLoc -= xdiff;
1094+
1095+
//PXJKFMG
1096+
// let xdiff = tm_x - timeline._xLoc;
1097+
// mark._xLoc -= xdiff;
1098+
10681099
update_all();
10691100

10701101
};//»
@@ -1161,13 +1192,13 @@ if (!Number.isFinite(sttm)){
11611192
reset_timeline();
11621193
return;
11631194
}
1164-
// let bounds = get_visual_time_bounds();
1165-
//log(bounds);
1166-
// let sttm = bounds.start;
1167-
//.start;
1168-
//log(sttm);
1169-
vid.currentTime = sttm;
1170-
tmdiv.innerHTML = get_main_time_str(sttm);
1195+
/*FSKROTKL: When scrolling the timeline, using the following 2 lines will:
1196+
1) Update the main video display
1197+
2) Cause the marker to move to the start time
1198+
*/
1199+
// vid.currentTime = sttm;
1200+
// tmdiv.innerHTML = get_main_time_str(sttm);
1201+
11711202
update_all();//This calls draw_ruler(), which calls new SetTimelineImages()
11721203
}
11731204
else{
@@ -1346,12 +1377,26 @@ const update_all = () => {//«
13461377
};//»
13471378
const center_to_time = tm => {//«
13481379
// tm = mag_sec_per_grid * Math.floor(tm/mag_sec_per_grid);
1380+
1381+
//If the timeline width is < the window width, just set _xLoc to 0
1382+
if (timeline._width < Main._w){
1383+
timeline._xLoc = 0;
1384+
update_all();
1385+
return;
1386+
}
1387+
//If the end marker is on the screen, flush it to the right edge of the app window,
1388+
//so that as much of the timeline is showing as possible (max number of preview frames).
1389+
if (flush_right_edge()){
1390+
update_all();
1391+
return;
1392+
}
13491393
let bounds = get_visual_time_bounds();
13501394
let ctr_time = (bounds.end + bounds.start)/2;
13511395
let off_secs = tm - ctr_time;
13521396
off_secs -= (off_secs % mag_sec_per_grid);
13531397
let pix_off = mag_pix_per_sec * off_secs;
13541398
timeline._xLoc-=pix_off;
1399+
//If the start marker is past the left edge of the app window, always flush it to to the left
13551400
if (timeline._xLoc > 0) timeline._xLoc = 0;
13561401
update_all();
13571402
};//»
@@ -1360,7 +1405,11 @@ const seek_to_time = async(tm, if_end)=>{//«
13601405
/*If the current time is the video duration, then doing a seek back to the beginning doesn't work.
13611406
The video stays at the end.
13621407
*/
1408+
//XKLGFREH
13631409
await await_seek(tm);
1410+
// await_seek(tm);
1411+
// vid.currentTime = tm;
1412+
// tmdiv.innerHTML = get_main_time_str(tm);
13641413
let ctr_time;
13651414
if (tm == viddur){
13661415
let start_x = GRID_W_HALF;
@@ -1377,6 +1426,7 @@ The video stays at the end.
13771426
const seek_to_end=async()=>{//«
13781427
timeline._xLoc = Main._w - timeline._width - GRID_W_HALF;
13791428
align_timeline();
1429+
//AQUEORK
13801430
// await seek_to_time(viddur-0.001, true);
13811431
seek_to_time(viddur-0.0001, true);
13821432
draw_ruler({addLast:true});
@@ -1605,7 +1655,7 @@ let {
16051655
} = get_visual_time_bounds();
16061656

16071657
if (invalid) {
1608-
cwarn("NOT UPDATING RULER!!!!");
1658+
cwarn("INVALID: RESET TIMELINE!!!!");
16091659
reset_timeline();
16101660
return;
16111661
}
@@ -1736,6 +1786,8 @@ update_all();
17361786
const flush_right_edge=()=>{//«
17371787
//Make sure the timeline location flushes with the right edge, when the visible
17381788
//duration is long enough
1789+
return false;
1790+
/*
17391791
let {duration, width} = get_visual_time_bounds();
17401792
17411793
if (duration < viddur && width < Main._w - GRID_W_HALF){
@@ -1744,6 +1796,7 @@ const flush_right_edge=()=>{//«
17441796
return true;
17451797
}
17461798
return false;
1799+
*/
17471800
}//»
17481801
const check_timeline_right_edge_for_underflow_and_center_to_time=(tm)=>{//«
17491802

@@ -1775,9 +1828,8 @@ given how wide it would be at the given magnification level.
17751828
}
17761829
}
17771830
flush_right_edge();
1778-
center_to_time(tm);
1779-
1780-
//log(get_visual_time_bounds());
1831+
update_all();
1832+
// center_to_time(tm);
17811833

17821834
}//»
17831835

@@ -1833,9 +1885,11 @@ const scroll_marks=()=>{//«
18331885
scroll_elem(m, m._time, MARK_X_OFF, bounds_start);
18341886
}
18351887
};//»
1888+
/*
18361889
const seek_to_timeline_start=async()=>{//«
18371890
await await_seek(get_visual_time_bounds().start);
18381891
};//»
1892+
*/
18391893
const try_seek_mark=async(if_popin)=>{//«
18401894
is_waiting = true;
18411895
let rv;
@@ -1970,8 +2024,9 @@ const create_mark=(usetime, id, if_auto)=>{//«
19702024
mrk._tcol=MARK_ON_COL;
19712025
mrk._fw="900";
19722026
cur_mark = mrk;
1973-
await seek_to_time(mrk._time);
1974-
center_to_curtime();
2027+
// await seek_to_time(mrk._time);
2028+
seek_to_time(mrk._time);
2029+
// center_to_curtime();
19752030
scroll_marks();
19762031
scroll_cluster_marks();
19772032
if (isNum(id)) stat(`Pos mark: #${mrk._id+1} (${tm.toFixed(3)}s)`);
@@ -2278,6 +2333,17 @@ this.onkeydown=(e,k)=>{//«
22782333
else if (k=="SPACE_"){
22792334
e.preventDefault();
22802335
if (vid.paused) {
2336+
let bounds = get_visual_time_bounds();
2337+
let start_diff = bounds.start - vid.currentTime;
2338+
if (start_diff > 0){
2339+
scroll_timeline("LEFT", {delta: start_diff * mag_pix_per_sec});
2340+
}
2341+
else{
2342+
let end_diff = vid.currentTime - bounds.end;
2343+
if (end_diff > 0) {
2344+
scroll_timeline("RIGHT", {delta: end_diff * mag_pix_per_sec});
2345+
}
2346+
}
22812347
vid.play();
22822348
vid.ontimeupdate = timeupdate;
22832349
}

list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11196","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100191","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/53836"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/11288","fs.js/28766","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44010","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2086","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1184"],"index.html/486","mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185134"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162675"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7792","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/959"],"sys",["config.js/9365","desk.js/219168","fs.js/67626","terminal.js/4300","three.js/3443","util.js/32970"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]
1+
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11196","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100191","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/55906"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/11288","fs.js/28766","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44010","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2086","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1184"],"index.html/486","mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185134"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162675"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7792","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/959"],"sys",["config.js/9365","desk.js/219168","fs.js/67626","terminal.js/4300","three.js/3443","util.js/32970"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]

0 commit comments

Comments
 (0)