Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Mikescops/11395591 to your computer and use it in GitHub Desktop.
Save Mikescops/11395591 to your computer and use it in GitHub Desktop.
Check if live stream of any video on Dailymotion is ON in JavaScript.
<script src="http://cdn.jsdelivr.net/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript">
// Import JSON data
var dailyAPI = "https://api.dailymotion.com/video/<video_id>?fields=onair";
$.getJSON(dailyAPI, function (json) {
// Set the variables from the results array
var live = json.onair;
console.log('Live : ', live);
if (live==true){
$('#live_display').html('STREAM ON'); // if the variable is set to true display this text.
}
});
</script>
<p id="live_display">STREAM OFF</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment