Skip to content

Instantly share code, notes, and snippets.

@ahmadalbakri
Last active December 11, 2015 02:18
Show Gist options
  • Save ahmadalbakri/4529092 to your computer and use it in GitHub Desktop.
Save ahmadalbakri/4529092 to your computer and use it in GitHub Desktop.
JS : Movideo Code
$(document).ready(function () {
function movideoLoaded(json) {
MOVIDEO.init({
apiKey: mv_api_key,
flashAppAlias: "flashApp",
iosAppAlias: "iPhone"
});
$('#player').player({
apiKey: mv_api_key,
flashAppAlias: "flashApp",
iosAppAlias: "iPhone"
});
function playMedia(e) {
e.preventDefault();
$('#player').player('play', {
mediaId: e.data.id
});
}
MOVIDEO.media.getPlaylistMedia({
id: mv_playlist_id,
omit: true,
extras: "getPlaylistMedia",
handler: VideoList,
errorHandler: errorHandler,
async: true
});
function getUrlVars() {
var vars = [],
hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var mediaid = getUrlVars()["movideo_m"];
MOVIDEO.media.getMedia({
id: mediaid,
omit: true,
extras: "getMedia",
handler: VideoDetail,
errorHandler: errorHandler,
async: true
});
function VideoList(object) {
var result = '';
$.each(object.list[0].media, function (i, item) {
result += '<li>\
<a href="?movideo_m=' + item.id + '" id=' + item.id + '>\
<span class="title">' + item.title + '</span>\
<img src=' + item.imagePath + '' + size + ' alt="' + item.title + '" />\
</a>\
</li>';
});
$(result).appendTo('.mv_video_list');
$(".mv_video_list").quickPagination();
}
function VideoDetail(object) {
var result2 = '';
$.each(object, function (i, item) {
result2 += '<h1>' + item.title + '</h1>\
<div class="mv_decription">' + item.description + '</div>'
});
$(result2).appendTo('.mv_details');
}
function errorHandler(event) {}
};
movideoLoaded();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment