Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4289814
video-thumbnails.html
matmarex (Bartosz Dziewoński)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
matmarex
Jul 19 2016, 11:52 PM
2016-07-19 23:52:41 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
video-thumbnails.html
View Options
<!doctype html>
<
html
>
<
meta
charset
=
"utf-8"
>
<
body
>
<
p
>
Choose a large number of video files here:
<
input
type
=
"file"
multiple
id
=
"files"
></
p
>
<
p
>
Thumbnails will appear below: (and exceptions will appear in your browser console)
</
p
>
<
div
id
=
"thumbnails"
></
div
>
<
script
>
var
filesInput
=
document
.
getElementById
(
'files'
);
var
thumbnailsContainer
=
document
.
getElementById
(
'thumbnails'
);
filesInput
.
addEventListener
(
'change'
,
function
()
{
for
(
var
i
=
0
;
i
<
filesInput
.
files
.
length
;
i
++
)
{
thumbnailVideo
(
filesInput
.
files
[
i
]
);
}
},
true
);
function
thumbnailVideo
(
file
)
{
var
first
=
true
;
var
video
=
document
.
createElement
(
'video'
);
video
.
addEventListener
(
'loadedmetadata'
,
function
()
{
// seek 2 seconds into video or to half if shorter
video
.
currentTime
=
Math
.
min
(
2
,
video
.
duration
/
2
);
video
.
volume
=
0
;
}
);
video
.
addEventListener
(
'seeked'
,
function
()
{
if
(
first
)
{
first
=
false
;
video
.
currentTime
=
Math
.
min
(
2
,
video
.
duration
/
2
);
return
;
}
setTimeout
(
function
()
{
var
canvas
=
document
.
createElement
(
'canvas'
);
var
context
=
canvas
.
getContext
(
'2d'
);
canvas
.
width
=
100
;
canvas
.
height
=
Math
.
round
(
canvas
.
width
*
video
.
videoHeight
/
video
.
videoWidth
);
context
.
drawImage
(
video
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
window
.
URL
.
revokeObjectURL
(
video
.
url
);
thumbnailsContainer
.
appendChild
(
canvas
);
},
500
);
}
);
url
=
window
.
URL
.
createObjectURL
(
file
);
video
.
src
=
url
;
}
</
script
>
</
body
>
</
html
>
File Metadata
Details
Attached
Mime Type
text/html
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3876592
Default Alt Text
video-thumbnails.html (1 KB)
Attached To
Mode
T136831: NS_ERROR_NOT_AVAILABLE
Attached
Detach File
Event Timeline
Log In to Comment