integration/js/edition.js
changeset 58 9e14b6f964fe
parent 55 cedadc7d039a
child 62 42919bf5d4e1
equal deleted inserted replaced
57:ba0de15418d1 58:9e14b6f964fe
    15         '#16a085', '#27ae60', '#2980b9', '#8e44ad', 
    15         '#16a085', '#27ae60', '#2980b9', '#8e44ad', 
    16         '#f39c12', '#d35400', '#c0392b', '#bdc3c7']
    16         '#f39c12', '#d35400', '#c0392b', '#bdc3c7']
    17 };
    17 };
    18 
    18 
    19 
    19 
    20 
    20 //position de la video setCurrentTime
       
    21 $(".indicateur-annotation").draggable({
       
    22     axis: "x",
       
    23     containment: "parent",
       
    24     drag: function(e, ui) {
       
    25         var t = myMedia.duration * parseInt(ui.helper.css("left")) / ( $(".timeline-annotations").width() - 2 * ui.helper.width() );
       
    26         myMedia.setCurrentTime(t);
       
    27     }
       
    28 });
       
    29 
       
    30 $('.timeline-annotations').bind('click', function(e){
       
    31     var x = e.pageX - $(this).offset().left;
       
    32     myMedia.setCurrentTime(myMedia.duration * x / $(this).width());
       
    33 });
    21 
    34 
    22 myProject.onLoad(function() {
    35 myProject.onLoad(function() {
    23 
       
    24 
       
    25 
       
    26 
       
    27 //load Annotations
       
    28 myProject.getAnnotationsByTypeTitle("annotations");
       
    29 
       
    30 
    36 
    31     $(".project-title").text(myProject.title);
    37     $(".project-title").text(myProject.title);
    32     
    38     
    33     myMedia = myProject.getCurrentMedia();
    39     myMedia = myProject.getCurrentMedia();
    34 
    40 
    35 //load Chapitre
    41 //load Chapitre
    36 var _chapters = myProject.getAnnotationsByTypeTitle("chapitrage");
    42 var _chapters = myProject.getAnnotationsByTypeTitle("chapitrage");
    37 if(_chapters.length){
    43 if(_chapters.length){
    38     $.each(_chapters, function(k, v){
    44     $.each(_chapters, function(k, v){
    39         var render = false;
    45         v.color = getRandomColor();
       
    46         chapters.push(v);
    40         if((k+1) == _chapters.length){
    47         if((k+1) == _chapters.length){
    41             render = true;
    48             renderChapter();
    42         }
    49         }
    43         newChapter(v, render);
       
    44     });
    50     });
    45 }
    51 }
    46 
    52 
    47 
    53 //load Annotations
       
    54 var _annotations = myProject.getAnnotationsByTypeTitle("annotations");
       
    55 if(_annotations.length){
       
    56     $.each(_annotations, function(k, v){
       
    57 
       
    58         v.color = getRandomColor();
       
    59         var type = v.content.mimetype.split('-');
       
    60         type = type[type.length-1]
       
    61         v.type = type;
       
    62 
       
    63         annotations.push(v);
       
    64         if((k+1) == _annotations.length){
       
    65             renderAnnotation();
       
    66         }
       
    67 
       
    68     });
       
    69 }
    48 
    70 
    49 
    71 
    50     //chargement des chapitres et annotations existants
    72     //chargement des chapitres et annotations existants
    51   //  loadInitChapters();
    73   //  loadInitChapters();
    52     loadInitAnnotation();
    74     //loadInitAnnotation();
    53 
    75 
    54     IriSP.htmlPlayer(
    76     IriSP.htmlPlayer(
    55         myMedia,
    77         myMedia,
    56         $(".main-video"),
    78         $(".main-video"),
    57         {
    79         {
   162         $('.input-image-'+typeImage).show();
   184         $('.input-image-'+typeImage).show();
   163     });
   185     });
   164 
   186 
   165 //select on bibliotheque
   187 //select on bibliotheque
   166 
   188 
   167     //video
   189     
   168     $('.popup').on('click', '.bibliotheque-video a', function(e){
       
   169         e.preventDefault();
       
   170 
       
   171         var url = $(this).attr('href');
       
   172         currentAnnotation.content.url = url;
       
   173 
       
   174         $('.popup').modal('hide');
       
   175         $.get('template.html', function(templates){
       
   176             var videoWrap = $('#tab-'+global.idAnnotation).find('.annotation-video-content'),
       
   177                 tplVideo = $(templates).filter('#tpl-video-row').html();
       
   178             videoWrap.empty().append(tplVideo);
       
   179         });
       
   180         
       
   181     });
       
   182     
   190     
   183 
   191 
   184     //confirmation suppression
   192     //confirmation suppression
   185     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   193     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   186 
   194 
   243     });
   251     });
   244 
   252 
   245 
   253 
   246 
   254 
   247     function loadFormChapter(idChapter){
   255     function loadFormChapter(idChapter){
       
   256 
       
   257         
       
   258 
   248         currentChapter = _.find(chapters, function(c){ return c.id == idChapter; });
   259         currentChapter = _.find(chapters, function(c){ return c.id == idChapter; });
   249         var chapterWrap = $('.chapter-widget-info'),
   260         var chapterWrap = $('.chapter-widget-info'),
   250             indexChapter = _.indexOf(chapters, currentChapter),
   261             indexChapter = _.indexOf(chapters, currentChapter),
   251             beginTangle = (indexChapter>0) ? true : false,
   262             beginTangle = (indexChapter>0) ? true : false,
   252             endTangle = (indexChapter<(chapters.length-1)) ? true : false;
   263             endTangle = (indexChapter<(chapters.length-1)) ? true : false;
   258             var tpl = $(templates).filter('#tpl-chapter-edit').html();
   269             var tpl = $(templates).filter('#tpl-chapter-edit').html();
   259             tpl = Mustache.render(tpl, currentChapter);
   270             tpl = Mustache.render(tpl, currentChapter);
   260             chapterWrap.empty().append(tpl);
   271             chapterWrap.empty().append(tpl);
   261             chapterWrap.find('.tag-it').tagit(tagitParam);
   272             chapterWrap.find('.tag-it').tagit(tagitParam);
   262         });
   273         });
       
   274 
       
   275         myMedia.setCurrentTime(currentChapter.begin);
   263     }
   276     }
   264 
   277 
   265 
   278 
   266 //supprimer
   279 //supprimer
   267 $('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){
   280 $('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){
   287     if($('#form-chapter-edit-'+idChapter).length){
   300     if($('#form-chapter-edit-'+idChapter).length){
   288         $('#form-chapter-edit-'+idChapter).remove();
   301         $('#form-chapter-edit-'+idChapter).remove();
   289     }
   302     }
   290 });
   303 });
   291 
   304 
       
   305 function getRandomColor(){
       
   306     return global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
       
   307 }
   292 //nouveau chapitre
   308 //nouveau chapitre
   293     function newChapter(dataChapter, render){
   309     function newChapter(dataChapter, render){
   294         var chapter = new IriSP.Model.Annotation(false, myProject);
   310         var chapter = new IriSP.Model.Annotation(false, myProject);
   295             chapter.setMedia(myMedia.id);
   311             chapter.setMedia(myMedia.id);
   296             chapter.setBegin(dataChapter.begin);
   312             chapter.setBegin(dataChapter.begin);
   297             chapter.setEnd(dataChapter.end);
   313             chapter.setEnd(dataChapter.end);
   298             chapter.title = dataChapter.title;
   314             chapter.title = dataChapter.title;
   299             chapter.description = dataChapter.description;
   315             chapter.description = dataChapter.description;
   300             chapter.keywords = dataChapter.keywords;
   316             chapter.keywords = dataChapter.keywords;
   301             chapter.color = global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)];
   317             chapter.color = getRandomColor();
   302     
   318     
   303         chapters.push(chapter);
   319         chapters.push(chapter);
   304         if(render){renderChapter();}
   320         renderChapter();
   305         loadFormChapter(chapter.id);
   321         loadFormChapter(chapter.id);
   306     }
   322     }
   307 
   323 
   308     $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
   324     $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
   309         e.preventDefault();
   325         e.preventDefault();
   344             return c.begin;
   360             return c.begin;
   345         });
   361         });
   346 
   362 
   347         chapterSegmentWrap.empty();
   363         chapterSegmentWrap.empty();
   348         chapterList.empty();
   364         chapterList.empty();
   349 
   365         $.get('template.html', function(templates){
   350         $.each(chapters, function(k, v){
   366             $.each(chapters, function(k, v){
   351             //form
   367 
   352             if($('#form-chapter-edit-'+v.id).length){
   368                 //segments
   353                 loadFormChapter(v.id);
   369                 var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration),
   354             }
   370                     segment = $('<li>'+v.title+'</li>').css({
   355             //segments
   371                         width : width,
   356             var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration),
   372                         backgroundColor : v.color
   357                 segment = $('<li>'+v.title+'</li>').css({
   373                     }).attr('id', v.id);
   358                     width : width,
   374         
   359                     backgroundColor : v.color
   375                 chapterSegmentWrap.append(segment);
   360                 }).attr('id', v.id);
   376 
   361     
   377                 //liste
   362             chapterSegmentWrap.append(segment);
       
   363 
       
   364             //liste
       
   365             $.get('template.html', function(templates){
       
   366                 var tplChapterRow = $(templates).filter('#tpl-chapter-row').html();
   378                 var tplChapterRow = $(templates).filter('#tpl-chapter-row').html();
   367                 tplChapterRow = Mustache.render(tplChapterRow, v);
   379                 tplChapterRow = Mustache.render(tplChapterRow, v);
   368                 chapterList.append(tplChapterRow);
   380                 chapterList.append(tplChapterRow);
   369 
       
   370             });
   381             });
   371         });
   382         });
   372     }
   383     }//renderChapter()
   373 
   384 
   374 //init
   385 //init
   375     function loadInitChapters(){//nouveau projet, 1 chapitre
   386     function loadInitChapters(){//nouveau projet, 1 chapitre
   376         var dataChapter = {
   387         var dataChapter = {
   377                 title : 'New',
   388                 title : 'New',
   553                 case 'audio':
   564                 case 'audio':
   554                     break;
   565                     break;
   555                 case 'video':
   566                 case 'video':
   556                     
   567                     
   557                     if(viewType.content.url != ""){
   568                     if(viewType.content.url != ""){
       
   569                    /*
   558                         var videoWrap = $(tabContent).find('.annotation-video-content'),
   570                         var videoWrap = $(tabContent).find('.annotation-video-content'),
   559                             tplVideo = $(templates).filter('#tpl-video-row').html();
   571                             tplVideo = $(templates).filter('#tpl-video-row').html();
       
   572                         tplVideo = Mustache.render(tplVideo, viewType.content);
   560                         videoWrap.empty().append(tplVideo);
   573                         videoWrap.empty().append(tplVideo);
       
   574 
       
   575     
       
   576                         var videoWrap = $(tabContent).find(".video-container"),
       
   577                             src = viewType.content.url;
       
   578                         getVideoPlayer(src, videoWrap);
       
   579 */
       
   580  var videoWrap = $(tabContent).find('.annotation-video-content');
       
   581                         renderVideoInfo(videoWrap, viewType.content);
       
   582    
   561                     }
   583                     }
       
   584 
       
   585                     
   562 
   586 
   563                     break;
   587                     break;
   564                 case 'text': 
   588                 case 'text': 
   565                     var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0];
   589                     var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0];
   566                     break;
   590                     break;
   578 
   602 
   579                 case 'slideshow': 
   603                 case 'slideshow': 
   580 
   604 
   581                     $(tabContent).find('.number-spin').spin(spinParam);
   605                     $(tabContent).find('.number-spin').spin(spinParam);
   582                     $(tabContent).find('.ui-sortable').sortable({
   606                     $(tabContent).find('.ui-sortable').sortable({
       
   607                         start: function (event, ui) {
       
   608                             $(ui.item).data("startindex", ui.item.index());
       
   609                         },
   583                         stop : function(event, ui){
   610                         stop : function(event, ui){
   584                             disabledBtnSortable($(this));
   611                             disabledBtnSortable($(this));
   585                         }
   612                         },
       
   613                         update : function(event, ui){
       
   614                             var oldIndex = ui.item.data("startindex"),
       
   615                                 newIndex = ui.item.index();
       
   616                             currentAnnotation.content.images.move(oldIndex, newIndex);
       
   617                         },
   586                     });
   618                     });
   587                     var diaporama = $(tabContent).find('#diaporama-'+idAnnotation),
   619                     var diaporama = $(tabContent).find('#diaporama-'+idAnnotation),
   588                         images = viewType.content.images;
   620                         images = viewType.content.images;
   589                     if(images.length){
   621                     if(images.length){
   590                         $.each(images, function(k,v){
   622                         $.each(images, function(k,v){
   651         $('#onglet-'+idAnnotation).remove();
   683         $('#onglet-'+idAnnotation).remove();
   652         $('.tab-content #tab-annotation-'+idAnnotation).remove();
   684         $('.tab-content #tab-annotation-'+idAnnotation).remove();
   653         $('#tab-list-annotation').tab('show');
   685         $('#tab-list-annotation').tab('show');
   654     }
   686     }
   655 
   687 
       
   688 //video
       
   689     function renderVideoInfo(videoWrap, dataVideo){
       
   690         $.get('template.html', function(templates){
       
   691             var tplVideo = $(templates).filter('#tpl-video-row').html();
       
   692             tplVideo = Mustache.render(tplVideo, dataVideo);
       
   693             
       
   694             videoWrap.empty().append(tplVideo);
       
   695 
       
   696             videoWrap = videoWrap.find(".video-container");
       
   697             getVideoPlayer(dataVideo.url, videoWrap);
       
   698         });
       
   699     }
       
   700     $('.popup').on('click', '.bibliotheque-video a', function(e){
       
   701         e.preventDefault();
       
   702 
       
   703         var url = $(this).attr('data-url'),
       
   704             title = $(this).attr('data-title'),
       
   705             description = $(this).attr('data-description');
       
   706 
       
   707         currentAnnotation.content.url = url;
       
   708         currentAnnotation.content.title = title;
       
   709         currentAnnotation.content.description = description;
       
   710 
       
   711         $('.popup').modal('hide');
       
   712 
       
   713         var videoWrap = $('#tab-annotation-'+currentAnnotation.id).find('.annotation-video-content');
       
   714         renderVideoInfo(videoWrap, currentAnnotation.content);
       
   715 /*
       
   716         $.get('template.html', function(templates){
       
   717             var videoWrap = $('#tab-annotation-'+currentAnnotation.id).find('.annotation-video-content'),
       
   718                 tplVideo = $(templates).filter('#tpl-video-row').html();
       
   719             tplVideo = Mustache.render(tplVideo, currentAnnotation.content);
       
   720             videoWrap.empty().append(tplVideo);
       
   721 
       
   722             var videoWrap = videoWrap.find(".video-container"),
       
   723                 src = url;
       
   724             getVideoPlayer(src, videoWrap);
       
   725         });
       
   726 */
       
   727         
       
   728     });
       
   729 
   656 //diaporama
   730 //diaporama
   657 
   731 
   658     //bibliotheque
   732     //bibliotheque
   659     $('.popup').on('click', '.bibliotheque-image a', function(e){
   733     $('.popup').on('click', '.bibliotheque-image a', function(e){
   660         e.preventDefault();
   734         e.preventDefault();
   661 
   735 
   662         var url = $(this).attr('href'),
   736         var url = $(this).attr('data-url'),
       
   737             title = $(this).attr('data-title'),
       
   738             description = $(this).attr('data-description'),
   663             image = {
   739             image = {
   664                 id : currentAnnotation.id,
   740                 id : currentAnnotation.id,
   665                 url : url,
   741                 url : url,
   666                 title : 'titre image',
   742                 title : title,
   667                 description : 'description azerty'
   743                 description : description
   668             };
   744             };
   669         currentAnnotation.content.images.push(image);
   745         currentAnnotation.content.images.push(image);
   670 
   746 
   671         var listDiaporama = $('#diaporama-'+currentAnnotation.id);
   747         var listDiaporama = $('#diaporama-'+currentAnnotation.id);
   672         addImageToDiaporama(listDiaporama, image);
   748         addImageToDiaporama(listDiaporama, image);
   684 
   760 
   685     //bouton up / down
   761     //bouton up / down
   686     $(document).on('click', '.ui-sortable .btn-sort', function(e){
   762     $(document).on('click', '.ui-sortable .btn-sort', function(e){
   687         e.preventDefault();
   763         e.preventDefault();
   688         var row = $(this).parents('tr.row-image-diaporama'),
   764         var row = $(this).parents('tr.row-image-diaporama'),
       
   765             oldIndex = row.index(),
   689             listDiaporama = $(this).parents('.list-image-diaporama');
   766             listDiaporama = $(this).parents('.list-image-diaporama');
   690 
   767 
   691         if($(this).hasClass('down'))
   768         if($(this).hasClass('down'))
   692             row.insertAfter(row.next());
   769             row.insertAfter(row.next());
   693         else if($(this).hasClass('up'))
   770         else if($(this).hasClass('up'))
   694             row.insertBefore(row.prev());
   771             row.insertBefore(row.prev());
   695 
   772 
       
   773         var newIndex = row.index();
       
   774         currentAnnotation.content.images.move(oldIndex, newIndex);
       
   775 
   696         disabledBtnSortable(listDiaporama);
   776         disabledBtnSortable(listDiaporama);
       
   777     });
       
   778 
       
   779     $('.tab-content').on('click','.btn-delete-image', function(e){
       
   780         e.preventDefault();
       
   781         var rowImage = $(this).parents('tr.row-image-diaporama'),
       
   782             index = rowImage.index();
       
   783 
       
   784         rowImage.remove();
       
   785         currentAnnotation.content.images.splice(index, 1);
   697     });
   786     });
   698 
   787 
   699     function disabledBtnSortable(listDiaporama){
   788     function disabledBtnSortable(listDiaporama){
   700         listDiaporama.find('.btn-sort.disabled').removeClass('disabled');
   789         listDiaporama.find('.btn-sort.disabled').removeClass('disabled');
   701         listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled');
   790         listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled');
   732     links = new Array();
   821     links = new Array();
   733     $.each(tbody.find('tr'), function(k, v){
   822     $.each(tbody.find('tr'), function(k, v){
   734         var urlLink = $(v).find('.url-link').val(),
   823         var urlLink = $(v).find('.url-link').val(),
   735             titleLink = $(v).find('.title-link').val(),
   824             titleLink = $(v).find('.title-link').val(),
   736             link = {
   825             link = {
   737                 uri : urlLink,
   826                 url : urlLink,
   738                 title : titleLink
   827                 title : titleLink
   739             };
   828             };
   740             links.push(link);
   829             links.push(link);
   741     });
   830     });
   742     currentAnnotation.content.links = links;
   831     currentAnnotation.content.links = links;
   899     }
   988     }
   900     return content;
   989     return content;
   901 }//getContentAnnotationByType
   990 }//getContentAnnotationByType
   902 
   991 
   903 
   992 
       
   993 
       
   994 
   904 //test
   995 //test
   905 //a = $(".wysiwyg").cleditor(wysiwygConfig);
   996 //a = $(".wysiwyg").cleditor(wysiwygConfig);
   906 
   997 
   907 
   998 
   908 $('.number-spin').spin(spinParam);
   999 $('.number-spin').spin(spinParam);
   926 $('.log-chapters').bind('click', function(e){
  1017 $('.log-chapters').bind('click', function(e){
   927     e.preventDefault();
  1018     e.preventDefault();
   928     console.log(chapters.length + ' chapitres',chapters);
  1019     console.log(chapters.length + ' chapitres',chapters);
   929 });
  1020 });
   930 });//ready
  1021 });//ready
       
  1022 
       
  1023 Array.prototype.move = function (old_index, new_index) {
       
  1024     if (new_index >= this.length) {
       
  1025         var k = new_index - this.length;
       
  1026         while ((k--) + 1) {
       
  1027             this.push(undefined);
       
  1028         }
       
  1029     }
       
  1030     this.splice(new_index, 0, this.splice(old_index, 1)[0]);
       
  1031     return this; // for testing purposes
       
  1032 };
       
  1033 
       
  1034 
       
  1035 function getVideoPlayer(src, videoWrap){
       
  1036 
       
  1037     var youtubeTemplate = _.template(
       
  1038         '<iframe width="<%- width %>" height="<%- height %>" src="http://www.youtube.com/embed/<%- ytid %>?rel=0&autoplay=<%- autoplay %>" frameborder="0"></iframe>'
       
  1039     );
       
  1040     
       
  1041     var htmlTemplate = _.template(
       
  1042         '<<%- type %> width="<%- width %>" controls="true" autoplay="<%- autoplay %>" src="<%- src %>"/>'
       
  1043     );
       
  1044     
       
  1045     var mediaW = 460,
       
  1046         mediaH = 345,
       
  1047         autoplay = false;
       
  1048 
       
  1049     
       
  1050     if (/^(https?:\/\/)?(www\.)?youtu\.?be/.test(src)) {
       
  1051         var urlparts = src.split(/[?&]/g),
       
  1052             ytid = "",
       
  1053             vtest = /^v=/;
       
  1054         urlparts.slice(1).forEach(function(p) {
       
  1055             if (/^v=/.test(p)) {
       
  1056                 ytid = p.replace(vtest,"");
       
  1057             }
       
  1058         });
       
  1059         if (!ytid) {
       
  1060             ytid = (urlparts[0].match(/[^\/]+$/) || [""])[0];
       
  1061         }
       
  1062         videoWrap.html(youtubeTemplate({
       
  1063             ytid: ytid,
       
  1064             width: mediaW,
       
  1065             height: mediaH,
       
  1066             autoplay: autoplay
       
  1067         }));
       
  1068         return;
       
  1069     }
       
  1070     
       
  1071     if (/^(https?:\/\/)?(www\.)?vimeo/.test(src)) {
       
  1072         $.ajax({
       
  1073             url: "http://vimeo.com/api/oembed.json",
       
  1074             dataType: "jsonp",
       
  1075             data: {
       
  1076                 width: mediaW,
       
  1077                 height: mediaH,
       
  1078                 url: src,
       
  1079                 autoplay: autoplay,
       
  1080                 color: "be4477",
       
  1081                 portrait: false,
       
  1082                 title: false,
       
  1083                 byline: false
       
  1084             },
       
  1085             success: function(data) {
       
  1086                 videoWrap.html(data.html);
       
  1087             }
       
  1088         });
       
  1089         return;
       
  1090     }
       
  1091     
       
  1092     if (/^(https?:\/\/)?(www\.)?dailymotion/.test(src)) {
       
  1093         $.ajax({
       
  1094             url: "http://www.dailymotion.com/services/oembed",
       
  1095             dataType: "jsonp",
       
  1096             data: {
       
  1097                 format: "json",
       
  1098                 maxwidth: mediaW,
       
  1099                 maxheight: mediaH,
       
  1100                 url: src
       
  1101             },
       
  1102             success: function(data) {
       
  1103                 videoWrap.html(data.html);
       
  1104             }
       
  1105         });
       
  1106         return;
       
  1107     }
       
  1108     
       
  1109     if (/^(https?:\/\/)?(www\.)?soundcloud\.com/.test(src)) {
       
  1110         $.ajax({
       
  1111             url: "http://soundcloud.com/oembed",
       
  1112             dataType: "jsonp",
       
  1113             data: {
       
  1114                 format: "js",
       
  1115                 show_comments: false,
       
  1116                 auto_play: autoplay,
       
  1117                 show_artwork: false,
       
  1118                 url: src,
       
  1119                 color: "63be6c"
       
  1120             },
       
  1121             success: function(data) {
       
  1122                 videoWrap.html(data.html);
       
  1123             }
       
  1124         });
       
  1125         return;
       
  1126     }
       
  1127     
       
  1128     var extension = (src.match(/\.([\d\w]+)$/) || ["",""])[1],
       
  1129         mimetype = 'video' + "/" + extension,
       
  1130         fallbacks = { "video/webm": "mp4", "video/mp4": "webm" },
       
  1131         canPlay = document.createElement("video").canPlayType(mimetype);
       
  1132     
       
  1133     if (!canPlay) {
       
  1134         src = src.replace(/\.[\d\w]+$/,"." + fallbacks[mimetype]);
       
  1135     }
       
  1136     
       
  1137     console.log(mimetype, canPlay, src);
       
  1138     
       
  1139     videoWrap.html(htmlTemplate({
       
  1140         type: 'video',
       
  1141         src: src,
       
  1142         width: mediaW,
       
  1143         height: mediaH,
       
  1144         autoplay: "" + autoplay
       
  1145     }));
       
  1146                 
       
  1147 }