Created
April 29, 2014 09:49
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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