player/js/player.js
changeset 69 ce5cdc22fbe4
parent 65 1da0c1382b07
child 71 af98a6dc9381
equal deleted inserted replaced
68:b163a938e9c3 69:ce5cdc22fbe4
    27                 }];
    27                 }];
    28             }
    28             }
    29         }
    29         }
    30     );
    30     );
    31     
    31     
       
    32     function preventRightClick(selector) {
       
    33         selector.on("contextmenu", function() {
       
    34             return false;
       
    35         });
       
    36     }
       
    37     
       
    38     preventRightClick($(".video-container video"));
       
    39         
    32     $(".media-duration").text(myMedia.duration);
    40     $(".media-duration").text(myMedia.duration);
    33     
    41     
    34     myMedia.on("timeupdate", function(t) {
    42     myMedia.on("timeupdate", function(t) {
    35         var pos = (100 * t / myMedia.duration) + "%";
    43         var pos = (100 * t / myMedia.duration) + "%";
    36         $(".media-position").text(t);
    44         $(".media-position").text(t);
   327                         slide.description.split(/\n/gm).map(function(l) {
   335                         slide.description.split(/\n/gm).map(function(l) {
   328                             return '<p>' + _.escape(l) + '</p>';
   336                             return '<p>' + _.escape(l) + '</p>';
   329                         }).join("")
   337                         }).join("")
   330                     );
   338                     );
   331                     imgel.fadeTo(400, 1);
   339                     imgel.fadeTo(400, 1);
       
   340                     preventRightClick(imgel);
   332                 }
   341                 }
   333                 
   342                 
   334                 var nextImage = function() {
   343                 var nextImage = function() {
   335                     currentslide = (currentslide + 1) % slides.length;
   344                     currentslide = (currentslide + 1) % slides.length;
   336                     annotationDiv.find(".slideshow-image").fadeTo(400, 0, showCurrentImage);
   345                     annotationDiv.find(".slideshow-image").fadeTo(400, 0, showCurrentImage);
   450                         success: function(data) {
   459                         success: function(data) {
   451                             annotationDiv.find(".media-frame").html(data.html);
   460                             annotationDiv.find(".media-frame").html(data.html);
   452                             positionDiv();
   461                             positionDiv();
   453                         }
   462                         }
   454                     });
   463                     });
   455                     return;
   464                     break;
   456                 }
   465                 }
   457                 
   466                 
   458                 if (/^(https?:\/\/)?(www\.)?dailymotion/.test(src)) {
   467                 if (/^(https?:\/\/)?(www\.)?dailymotion/.test(src)) {
   459                     $.ajax({
   468                     $.ajax({
   460                         url: "http://www.dailymotion.com/services/oembed",
   469                         url: "http://www.dailymotion.com/services/oembed",
   468                         success: function(data) {
   477                         success: function(data) {
   469                             annotationDiv.find(".media-frame").html(data.html);
   478                             annotationDiv.find(".media-frame").html(data.html);
   470                             positionDiv();
   479                             positionDiv();
   471                         }
   480                         }
   472                     });
   481                     });
   473                     return;
   482                     break;
   474                 }
   483                 }
   475                 
   484                 
   476                 if (/^(https?:\/\/)?(www\.)?soundcloud\.com/.test(src)) {
   485                 if (/^(https?:\/\/)?(www\.)?soundcloud\.com/.test(src)) {
   477                     $.ajax({
   486                     $.ajax({
   478                         url: "http://soundcloud.com/oembed",
   487                         url: "http://soundcloud.com/oembed",
   488                         success: function(data) {
   497                         success: function(data) {
   489                             annotationDiv.find(".media-frame").html(data.html);
   498                             annotationDiv.find(".media-frame").html(data.html);
   490                             positionDiv();
   499                             positionDiv();
   491                         }
   500                         }
   492                     });
   501                     });
   493                     return;
   502                     break;
   494                 }
   503                 }
   495                 
   504                 
   496                 var extension = (src.match(/\.([\d\w]+)$/) || ["",""])[1],
   505                 var extension = (src.match(/\.([\d\w]+)$/) || ["",""])[1],
   497                     mimetype = annotationinfo.type + "/" + extension,
   506                     mimetype = annotationinfo.type + "/" + extension,
   498                     fallbacks = { "video/webm": "mp4", "video/mp4": "webm", "audio/ogg": "mp3", "audio/mp3": "ogg" },
   507                     fallbacks = { "video/webm": "mp4", "video/mp4": "webm", "audio/ogg": "mp3", "audio/mp3": "ogg" },
   512                 
   521                 
   513                 media.on("loadedmetadata", function() {
   522                 media.on("loadedmetadata", function() {
   514                     positionDiv();
   523                     positionDiv();
   515                 });
   524                 });
   516                 
   525                 
       
   526                 preventRightClick(media);
       
   527                 
   517                 annotationDiv.find(".media-frame").html(media);
   528                 annotationDiv.find(".media-frame").html(media);
   518                 return;
       
   519                 
   529                 
   520             break;
   530             break;
   521             
   531             
   522             case "text":
   532             case "text":
   523                 
   533                 
   524                 var text = annotationinfo.annotation.content.text || annotationinfo.annotation.description;
   534                 var text = annotationinfo.annotation.content.text || annotationinfo.annotation.description;
   525                 
   535                 
   526                 switch (annotationinfo.annotation.content.markup) {
   536                 switch (annotationinfo.annotation.content.markup) {
   527                     case "html":
   537                     case "html":
   528                         annotationDiv.find(".text-contents").html(text);
   538                         annotationDiv.find(".text-contents").html(text);
   529 
       
   530                         var ps = annotationDiv.find(".text-contents>p"),
       
   531                             groups = [],
       
   532                             last, group;
       
   533                         ps.each(function(i, e) {
       
   534                             if (last && group && last.nextElementSibling === e) {
       
   535                                 group.contents.push(e);
       
   536                             } else {
       
   537                                 group = {
       
   538                                     master: e,
       
   539                                     contents: [e.cloneNode(true)]
       
   540                                 }
       
   541                                 groups.push(group);
       
   542                             }
       
   543                             last = e;
       
   544                         });
       
   545                         groups.forEach(function(g) {
       
   546                             $(g.master).replaceWith($('<div class="column-group">').append(g.contents));
       
   547                         });
       
   548 
       
   549                     break;
   539                     break;
   550                     default:
   540                     default:
   551                         annotationDiv.find(".text-contents").html(
   541                         annotationDiv.find(".text-contents").html(
   552                             text.split(/\n/gm).map(function(l) {
   542                             text.split(/\n/gm).map(function(l) {
   553                                 return '<p>' + _.escape(l) + '</p>';
   543                                 return '<p>' + _.escape(l) + '</p>';
   554                             }).join("")
   544                             }).join("")
   555                         );
   545                         );
   556                     break;
   546                     break;
   557                 }
   547                 }
   558                 annotationDiv.find(".text-contents a").attr("target","_blank");
   548                 annotationDiv.find(".text-contents a").attr("target","_blank");
       
   549                 annotationDiv.find(".text-contents").css({
       
   550                     "max-height": $(".main-video").height() - 140
       
   551                 });
   559                 
   552                 
   560             break;
   553             break;
   561             
   554             
   562             case "link":
   555             case "link":
   563             
   556             
   564                 var linkTemplate = _.template('<p><a href="<%- url %>" target="_blank"><%- title %></a></p>');
   557                 var linkTemplate = _.template('<p><a href="<%- url %>" target="_blank"><%- title %></a></p>');
   565                 
   558                 
   566                 annotationDiv.find(".link-contents").html(
   559                 annotationDiv.find(".link-contents").html(
   567                     annotationinfo.annotation.content.links.map(linkTemplate).join("")
   560                     annotationinfo.annotation.content.links.map(linkTemplate).join("")
   568                 );
   561                 ).css({
   569                 
   562                     "max-height": $(".main-video").height() - 140
   570             break;
   563                 });
   571         }
   564                 
   572         
   565             break;
   573         positionDiv(true);
   566         }
       
   567         
       
   568         positionDiv();
   574         
   569         
   575     }
   570     }
   576     
   571     
   577     $(".video-container").click(function() {
   572     $(".video-container").click(function() {
   578         if (currentAnnotation) {
   573         if (currentAnnotation) {