2017-07-05 21:23:55 +02:00
|
|
|
<div class="panel">
|
2017-07-06 03:26:33 +02:00
|
|
|
<div id="asset-placeholder" data-filepath="{{{filePath}}}">
|
2017-07-06 03:38:22 +02:00
|
|
|
<p> video loading... </p>
|
2017-07-05 22:51:25 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="/socket.io/socket.io.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var socket = io();
|
2017-07-06 03:26:33 +02:00
|
|
|
var filePath = document.getElementById('asset-placeholder').dataset.filepath;
|
|
|
|
console.log(filePath);
|
|
|
|
if (filePath) {
|
|
|
|
// send request for the file
|
|
|
|
socket.emit('asset-request', filePath);
|
|
|
|
}
|
|
|
|
// wait for the file to be sent
|
|
|
|
socket.on('asset-transfer', function(data) {
|
|
|
|
switch (data.type) {
|
|
|
|
case 'image/jpeg':
|
|
|
|
case 'image/gif':
|
|
|
|
case 'image/png':
|
|
|
|
const base64Image = 'data:' + data.type + ';base64,' + data.buffer;
|
|
|
|
document.getElementById("asset-placeholder").innerHTML = '<img class="show-image" src="' + base64Image + '"/>';
|
|
|
|
break;
|
|
|
|
case 'video/mp4':
|
|
|
|
const base64video = 'data:' + data.type + ';base64,' + data.buffer;
|
2017-07-06 03:38:22 +02:00
|
|
|
document.getElementById("asset-placeholder").innerHTML = '<video controls class="show-video"> <source src="' + base64video + '"></video>';
|
2017-07-06 03:26:33 +02:00
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
});
|
2017-07-05 22:51:25 +02:00
|
|
|
</script>
|