Video.js not playing only audio with black screen - html5-video

I have initialized video js player on my webpage
and i have a function that is triggered on a button click to load source to the video . and show the player and start playing it (auto start is set to true)
function playVid(x) {
videojs("vidPlay").src({type: "video/mp4", src: "http://www.domain.com/getVid?id=" + x});
showPlayer();
}
this works very well in firefox but in other browsers it only plays the audio with black video...
what is wrong here ?
how can i fix this ?

Related

BXSlider event when video starts playing

I am using BXSlider to display various videos. I am trying to fade out an overlay when the first video starts playing.
I have tried hooking into onSliderLoad but that trigger before the video has started playing.
Anyone know if there is a way I can detect when the video has actually started playing?
Listen for the playing event.
Demo
var vid = document.getElementById('vid');
vid.addEventListener('playing', function(e) {
console.log('Video has started');
});
<video id='vid' src='http://media6000.dropshots.com/photos/1381926/20170326/005611.mp4' width='320' height='180' controls autoplay></video>

html5 video // autoplay

I am showing a div width Text over the poster image while the video is loading and when the video is paused.
How can I detect the moment the video is fully loaded and autoplay starts? Because then, the div should be hidden.
It you have defined autoplay then detect using the play event:
video.onplay = function() { /* remove overlay here */ };
alternatively use canplay or canplaythrough when you want to manually trigger play.

Video JS - Change Play Icon in ControlBar with Replay Icon After Video End

I have a videojs player. I want to chage play icon in controlbar with replay icon when the video has end.
You can see like youtube player :
This is my code :
<script>
videojs("my_video_1").ready(function(){
var vid = this;
vid.on("ended", function(){
alert ("I want to change play icon in cotrolbar with replay icon");
// i dont know to chage play icon when the video is finish
});
});
This is my full code. You can run it via jsbin: http://jsbin.com/fijefi/2/
thank you
You don't even need javascript to do this. You can change the play icon via CSS.
In the default LESS file there are two states for the play button:
.vjs-default-skin .vjs-play-control:before {
content: #play-icon;
}
.vjs-default-skin.vjs-playing .vjs-play-control:before {
content: #pause-icon;
}
You just need to add a third state when the video has ended. There is already a CSS class for that. You'll end up with something that looks like:
.vjs-default-skin.vjs-ended .vjs-play-control:before {
content: "YOUR REPLY ICON";
}

Detecting if sound is playing in selenium

I have some 3rd party sites I load in an iframe for a project I'm working on, but I need to somehow detect if those sites are playing any sound. I'm not seeing any methods with WebDriver to see if sound is playing in the browser, is there some other way to query the VM itself?
In the modern HTML5 age, for anyone checking to see if audio is playing, we can use the audio and video tag in html5 to check for sound playback using the javascript executor. Below code is in java and selenium
boolean isPlaying = false;
// find all frames and iterate over it.
// This finds only the top level frames. Frames inside frames are not considered for this answer
for (WebElement iframe: driver.findElements(By.cssSelector('iframe'))) {
driver.switchTo().frame(iframe);
// find all the video and audio tags within the frame
for (WebElement player: driver.findElements(By.cssSelector('audio,video'))) {
// check if the argument paused is true or false.
// In case audio or video is playing, paused is false
String paused = (String) ((JavascriptExecutor) driver).executeScript('return arguments[0].paused', player);
if (paused.equals('false')) {
isPlaying = true;
break;
}
}
// switch out from the frame
driver.switchTo().defaultContent();
if (isPlaying)
break;
}
The above code can be modified to track frames within frames as well by changing it into a recursive function

Anythingslider html 5 video autoplay

please i need your help folks!
I'm using Anythingslider to slide between HTML5 video and other content, but when I add autoplay attribute in video tag, Anythingslider plays just audio.
Are you sure the video is not hidden behind another element? Play with the z-index as the video should be visible. I've had a few issues with this in the past, such as the video flickering in and out of visibility on scroll.
I ended up playing the videos in a light box since anything slider would leave the video playing as the carousel continued to scroll. Also, if you use an infinite scroller there were also issues with it playing the video in two places.
Providing you are using something like JW Player you will be able to set up some actions to pause the video on slide or similar but basic youtube embeds will be an issue.
Don't add the autoplay attribute to HTML5 video. What is probably happening is that the cloned copy of the video (first and last slides only) is playing the video, but all you hear is the audio since the panel is not in view. The reason you don't want to autoplay is because it will still autoplay even if AnythingSlider starts with another slide visible, and it won't stop until you cycle through the panels.
If you want the video to autoplay when the panel is visible, you'll have to add some script into the completed callback (video extension is not required with the code below; demo):
var playvid = function(slider) {
var vid = slider.$currentPage.find('video');
if (vid.length) {
// autoplay
vid[0].play();
}
};
$('#slider').anythingSlider({
// Autoplay video in initial panel, if one exists
onInitialized: function(e, slider) {
playvid(slider);
},
// pause video when out of view
onSlideInit: function(e, slider) {
var vid = slider.$lastPage.find('video');
if (vid.length && typeof(vid[0].pause) !== 'undefined') {
vid[0].pause();
}
},
// play video
onSlideComplete: function(slider) {
playvid(slider);
},
// pause slideshow if video is playing
isVideoPlaying: function(slider) {
var vid = slider.$currentPage.find('video');
return (vid.length && typeof(vid[0].pause) !== 'undefined' && !vid[0].paused && !vid[0].ended);
}
});​