Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
cf152318
Commit
cf152318
authored
May 19, 2020
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
page that plays mjpeg in html canvas
parent
03fe3594
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
mjpeg.html
src/php_top/mjpeg.html
+69
-0
No files found.
src/php_top/mjpeg.html
0 → 100644
View file @
cf152318
<html>
<head>
<style>
body
{
margin
:
0px
;
}
canvas
{
height
:
100%
;
border
:
0px
solid
red
;
}
</style>
</head>
<body>
<canvas
id=
'cnv'
></canvas>
<script>
const
IMGSRV_PORT0
=
2323
;
const
params
=
new
URLSearchParams
(
location
.
search
);
const
port
=
params
.
get
(
'port'
)
||
0
;
if
(
params
.
get
(
'port'
)
===
null
){
let
s
=
""
;
if
(
location
.
search
===
""
){
s
=
"?port="
+
port
;
}
else
{
s
=
location
.
search
+
"&port="
+
port
;
}
window
.
history
.
pushState
(
''
,
''
,
location
.
pathname
+
s
);
}
let
imgsrv_port
=
IMGSRV_PORT0
+
parseInt
(
port
);
let
cnv
=
document
.
getElementById
(
'cnv'
);
let
ctx
=
cnv
.
getContext
(
'2d'
);
let
img
=
new
Image
();
img
.
onload
=
function
()
{
canvas_resize
();
refreshCanvas
();
};
img
.
src
=
location
.
origin
+
":"
+
imgsrv_port
+
"/mimg"
;
window
.
addEventListener
(
"resize"
,
()
=>
{
canvas_resize
();
});
///////////////////////////////////////////////////////////////////////////////////
function
canvas_resize
(){
ctx
.
canvas
.
width
=
img
.
width
;
ctx
.
canvas
.
height
=
img
.
height
;
}
window
.
setInterval
(
"refreshCanvas()"
,
5
);
function
refreshCanvas
(){
try
{
ctx
.
drawImage
(
img
,
0
,
0
,
ctx
.
canvas
.
width
,
ctx
.
canvas
.
height
);
}
catch
(
err
){
img
.
src
=
location
.
origin
+
":2323/mimg"
;
}
};
</script>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment