I'm trying to play videos (mp4) in an window loaded with Electron.
Weird thing : it works fine with only one video, with the others it shows a black screen. The only difference between all videos are their width and height (does that matter ?). Also, in a browser window all videos play just fine.
Here's the code that load windows in electron :
let mainWindow;
let playerWindow;
app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit();
}
});
app.on('ready', function() {
mainWindow = new BrowserWindow({
title: 'MasterGameApp',
x: 910,
y: 500,
width: 800,
height: 460,
show: true,
resizable: false,
transparent: false
});
playerWindow = new BrowserWindow({
title: 'playerView',
x: 2250,
y: 50,
width: 1005,
height: 540,
show: true,
transparent: false,
fullscreen : true
});
mainWindow.loadURL('http://localhost:8889');
mainWindow.setMenuBarVisibility(false);
mainWindow.setAutoHideMenuBar(true);
playerWindow.loadUrl('http://localhost:8889/playerView');
playerWindow.setMenuBarVisibility(false);
playerWindow.setAutoHideMenuBar(true);
mainWindow.on('closed', function() {
playerWindow.close();
playerWindow = null;
mainWindow = null;
});
});
The videos url are simply given to a video tag inside a JS script like this $('#someDiv').append('<video id=\'backgroundvid\' autoplay><source src=\''+ content +'\' type=\'video/mp4\'></video>');
I don't understand why the browser can play every video but the electron window can't ... Thank's in advance
Ummm hey. I just saw the beginning of your URL property for the video tag is out of the inverted commas.
What you have:
$('#someDiv').append('<video id=\'backgroundvid\' autoplay><source src=\''+ content +'\' type=\'video/mp4\'></video>');
What you should have:
$('#someDiv').append('<video id=\'backgroundvid\' autoplay><source src="\''+ content +'\' type=\'video/mp4\'"></video>');
Have you tried changing that?
Stay lit; keep doing Electron. I am a great fan of it and can see its potential for future desktop applications. 👍👍👍
NOTE: Also, I am not sure what your CORS settings are or anything, but if it it trying to load videos locally, it may not let you.
Related
I have a lottie animation that I have integrated it in my code. I want to show a specific frame on initial load and when the user hover it the animation should start from the beginning and completes it.
This is what I want to show in first load -
And this is the complete animation -
This is my code
let iconMenu = document.querySelector('.bodymovinanim1');
let animationMenu = bodymovin.loadAnimation({
container: iconMenu,
renderer: 'svg',
loop: false,
autoplay: false,
path: "https://assets2.lottiefiles.com/packages/lf20_txJcSM.json",
});
animationMenu.addEventListener('DOMReady',function(){
animationMenu.playSegments([1,200],true);
});
iconMenu.addEventListener('mouseover', (e) => {
animationMenu.play();
});
This is my fiddle
Can anyone please help me?
It looks like you're using an outdated version of Lottie in this fiddle. Once that's updated you probably want to pass through the initialSgments option instead of using playSegments. In this case you can remove your DOMReady code block entirely and it works as expected. The one issue with your animation is the circle by itself doesn't actually exist. There's a tiny dot of green on the only half frame where that circle is completed before the rest starts animating. 51.5 is the closest from you can get, here's a fiddle showing it
let iconMenu = document.querySelector('.bodymovinanim1');
let animationMenu = bodymovin.loadAnimation({
container: iconMenu,
renderer: 'svg',
loop: false,
autoplay: false,
path: "https://assets2.lottiefiles.com/packages/lf20_txJcSM.json",
initialSegment: [51.5, 200],
});
iconMenu.addEventListener('mouseover', (e) => {
animationMenu.play();
});
I am using html2canvas and jsDoc. I am rendering my current component html to pdf.
But somehow color of other component is overlapping to the current component after I download the pdf. This is Angular component.
Screenshots :
Screenshot from application
Screenshot from pdf viewer (Sidebar visible):
3.Screenshot from pdf viewer (Sidebar hidden):
You can see the color is overlapping from submit button till end.
Code :
downloadPdf() {
html2canvas(document.querySelector(".main-content")).then(canvas => {
var pdf = new jsPDF('p', 'pt', [canvas.width, canvas.height]);
var imgData = canvas.toDataURL("image/jpeg",1.0);
pdf.addImage(imgData, 0, 0, canvas.width, canvas.height);
pdf.save('image.pdf');
});
}
Any guess why that color is overlapping? Any other solution to render HTML to pdf?
maybe my answer help someone. I resolved similar issue by adding a scale property
html2canvas(document.querySelector('#preview_modal'), {
allowTaint: false,
useCORS: true,
scale: 2,
})
I am using Wistia for video hosting and the wistia player for playing the video in my website. I need to detect video player events like 'pause' and 'end' and play another video based on some criteria.
The following code changes the video being played when the video is paused. This code works perfectly on Chrome and Safari. But in Firefox (Ver 29), the video is played through the flash plugin and the video player events like 'pause', 'end' are not generated.
<script>
var firstVideoId = "993554ba94",
var secondVideoId = "9dc0dc7d3a";
firstVideo = Wistia.embed( firstVideoId , {
container: "video_container",
playerPreference: "html5"
});
firstVideo.bind('pause',function(){
// Play next video.
changeVideo();
});
firstVideo.play();
function changeVideo() {
// Remove first video and play the second.
firstVideo.remove();
secondVideo = Wistia.embed( secondVideoId , {
container: "video_container",
playerPreference: "html5",
autoPlay: true
});
secondVideo.bind('pause',function() {
changeBack();
});
}
function changeBack() {
// Remove second video and play the first
secondVideo.remove();
firstVideo = Wistia.embed( firstVideoId , {
container: "video_container",
playerPreference: "html5",
autoPlay: true
});
firstVideo.bind('pause',function() {
changeVideo();
});
firstVideo.play();
}
</script>
Here are my questions:
How to play the video as HTML5 in Firefox (playerPreference is not helping).
Is there a way to capture the events when the flash plugin is used to play the video.
i have a chrome extension which automatically open a window using
window.open();
when user open some specific websites.
what i want is the new window which i open from the background script through window.open() should be displayed behind the current webiste opened by the user.
i have tried window.open properties like alwaysLowered=1, z-lock=1 etc. but not working.
Also tried.....
var w = window.open('url');
if(w){
w.blur();
window.focus();
}
all these have no effect on chrome. can anybody help?
If you don't need the handle to the opened window (returned by window.open), you can use the chrome.windows API's methods create and update:
In background.js:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.windows.create({ url: "http://www.google.com/" }, function(win) {
chrome.windows.update(win.id, { focused: false });
});
});
Theoretically, passing the focused: false property in the createInfo argument should achieve the same result in one step, but it is not working for me with Chrome version 31.0.1650.57 on Windows.
UPDATE:
The above code seems to not "blur" the window on Macs. To overcome this (while determining the position and size of the new window - as per OP's comment) use the following code:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.windows.create({
url: "http://www.google.com/",
width: 430,
height: 150,
top: top_popup,
left: left_popup
}, function(win) {
chrome.windows.update(tab.windowId, { focused: true });
});
});
chrome.windows.getCurrent(function(winCurrent){
chrome.windows.create({url:url, function(win){
chrome.windows.update(winCurrent.id, {focused: true});
});
});
Try this, its fast so viewer doesn't feel much
I'm using popcorn.js with Vimeo. I would like to play my Vimeo video programmatically, but I can't seem to get the basic play() method to work for Vimeo videos.
The example code from popcorn.js.org doesn't work for me. The video does not "play right away."
document.addEventListener("DOMContentLoaded", function () {
var example = Popcorn.vimeo(
'#video',
'http://player.vimeo.com/video/25107077');
// add a footnote at 2 seconds, and remove it at 6 seconds
example.footnote({
start: 2,
end: 6,
text: "Pop!",
target: "footnotediv"
});
// play the video right away
example.play();
}, false);
Move example.play() into an appropriate listener. This should work:
example.listen( 'canplaythrough', function() {
example.play();
});