File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
crates/rs-gui/try-wry/examples/streaming Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Document</ title >
7+ </ head >
8+ < body >
9+ < p > Enter a path to a video to play, then hit Enter or click Start</ p >
10+ < form id ="form-el ">
11+ < input id ="input-el " />
12+ < button type ="submit "> Start</ button >
13+ </ form >
14+ < video id ="video-el " autoplay controls > </ video >
15+ </ body >
16+
17+ < script >
18+ function convertFileSrc ( filePath ) {
19+ const userAgent = navigator . userAgent . toLowerCase ( ) ;
20+ const android = userAgent . indexOf ( "android" ) > - 1 ;
21+ const windows = userAgent . indexOf ( "windows" ) > - 1 ;
22+
23+ const path = encodeURIComponent ( filePath ) ;
24+ return windows || android
25+ ? `http://stream.localhost/${ path } `
26+ : `stream://localhost/${ path } ` ;
27+ }
28+
29+ const formEl = document . querySelector ( "#form-el" ) ;
30+ const inputEl = document . querySelector ( "#input-el" ) ;
31+ const videoEl = document . querySelector ( "#video-el" ) ;
32+
33+ formEl . addEventListener ( "submit" , ( e ) => {
34+ e . preventDefault ( ) ;
35+ videoEl . src = convertFileSrc ( inputEl . value ) ;
36+ } ) ;
37+ </ script >
38+ </ html >
You can’t perform that action at this time.
0 commit comments