Created
November 3, 2012 19:54
-
-
Save MeoMix/4008497 to your computer and use it in GitHub Desktop.
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
var closestvideo = { | |
video: null, | |
difference: Number.MAX_VALUE | |
}; | |
var videos = json.feed.entry; | |
$.each(videos, function () { | |
var duration = this.media$group.yt$duration.seconds; | |
console.log("song duration:", song.duration); | |
var durationdifference = Math.abs((parseFloat(song.duration) - duration)); | |
if (closestvideo.difference > durationdifference) { | |
closestvideo.video = this; | |
closestvideo.difference = durationdifference; | |
} | |
}); | |
var closestvideo = _.sortBy(videos, function (video) { | |
var duration = video.media$group.yt$duration.seconds; | |
var durationdifference = Math.abs((parseFloat(song.duration) - duration)); | |
return durationdifference; | |
})[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment