Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
// Handle fullscreen change for the Windows platform
const win32FullScreenChange = e => {
const win = remote.BrowserWindow.getFocusedWindow();
if ("win32" === process.platform) {
win.setMenu(
document.webkitIsFullScreen ? null : remote.Menu.getApplicationMenu()
);
}
};
// use renderAudio override for mp3
if (VideoPlayer.MP3_CONTENT_TYPES.indexOf(contentType) > -1) {
this.renderAudio(container, null, false);
} else {
player.append(
this.file(),
container,
{ autoplay: false, controls: true },
renderMediaCallback.bind(this)
);
}
document.addEventListener("keydown", this.togglePlayListener);
const mediaElement = this.refs.media.children[0];
if (mediaElement) {
mediaElement.addEventListener("click", this.togglePlayListener);
mediaElement.addEventListener(
"loadedmetadata",
loadedMetadata.bind(this),
{
once: true,
this.renderFile();
}
} else {
// Render default viewer: render-media (video, audio, img, iframe)
const currentMediaContainer = this.mediaContainer.current;
// Clean any potential rogue instances
while (currentMediaContainer.firstChild) {
currentMediaContainer.removeChild(currentMediaContainer.firstChild);
}
// A slight delay is a hacky way to improve support for videos that aren't web-optimized
// Works... slightly better than not having it ¯\_(ツ)_/¯
await this.sleep(400);
player.append(
{
name: fileName,
createReadStream: opts => fs.createReadStream(downloadPath, opts),
},
container,
{ autoplay: true, controls: true },
renderMediaCallback.bind(this)
);
}
const mediaElement = container.children[0];
if (mediaElement) {
if (position) {
mediaElement.currentTime = position;
}
isRenderMediaSupported() {
// Files supported by render-media
const { contentType } = this.props;
return Object.values(player.mime).indexOf(contentType) !== -1;
}
isRenderMediaSupported() {
// Files supported by render-media
const { contentType } = this.props;
return (
Object.values(player.mime).indexOf(contentType) !== -1 ||
MediaPlayer.SANDBOX_TYPES.indexOf(contentType) > -1
);
}
self._store.get(0, function(e, buffer) {
if(e) { return cb(e); }
var file = {
name: `file${self._getExtension()}`,
createReadStream: function(opts) {
opts = opts || {};
return from([
buffer.slice(opts.start || 0, opts.end || (buffer.length - 1))
]);
}
};
render.append(file, rootElem, cb);
});
};
function append (file, el, cb) {
validateFile(file)
if (typeof el === 'string') el = document.querySelector(el)
if (!cb) cb = function () {}
var filetype = exts[path.extname(file.name).toLowerCase()]
if (filetype === 'csv') return csv(file, el, cb)
if (filetype === 'geojson' && geojson) return geojson(file, el, cb)
if (filetype === 'raw') return raw(file, el, cb)
media.append(file, el, cb)
}
appendTo (elem, opts, cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
render.append(this, elem, opts, cb)
}
append (file) {
render.append(file, this)
}
}
File.prototype.appendTo = function appendTo(rootElem, cb) {
cb = cb || function () {};
var file = {
name: `file${self._getExtension()}`,
createReadStream: function() {
return this.createReadStream();
}
};
render.append(file, rootElem, cb);
};
_getMimeType () {
return render.mime[path.extname(this.name).toLowerCase()]
}