script.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. $(document).ready(function() {
  2. var _video = document.getElementById('video'), _fps = 24;
  3. var _timeline, _timeline_container = document.getElementById('timeline'), _tl_data_ar=[], _tl_items;
  4. function init(){
  5. console.log("Init");
  6. // preload all pictures before launching
  7. // setTimeout(function(){
  8. // play();
  9. // }, 5000);
  10. getMetaData();
  11. // setupTimeline();
  12. };
  13. function getMetaData(){
  14. console.log('getMetaData');
  15. // $.getJSON('metadata/frame.json',function(data){
  16. // setUpData(data.frames)
  17. // });
  18. $.ajax({
  19. dataType:"json",
  20. url:'metadata/frames.json',
  21. success:setUpData
  22. });
  23. console.log('getMetaData END');
  24. };
  25. function setUpData(data){
  26. console.log("setUpData");
  27. // console.log("data", data);
  28. var frame;
  29. for (var i in data.frames) {
  30. console.log(data.frames[i]);
  31. _tl_data_ar.push({
  32. start:new Date(data.frames[i].time),
  33. id:data.frames[i].frame
  34. });
  35. }
  36. setupTimeline();
  37. };
  38. function setupTimeline(){
  39. // Create a DataSet (allows two way data-binding)
  40. _tl_items = new vis.DataSet(_tl_data_ar);
  41. // Configuration for the Timeline
  42. // var options = {};
  43. // Create a Timeline
  44. _timeline = new vis.Timeline(_timeline_container, _tl_items, {});
  45. _timeline.on('select', onSelectTimelineItem)
  46. }
  47. function onSelectTimelineItem(props){
  48. console.log("onSelectTimelineItem", props);
  49. seekVideoTo(props.items[0]);
  50. };
  51. function seekVideoTo(f){
  52. console.log("seekVideoTo frame", f);
  53. _video.pause();
  54. _video.currentTime = f/_fps;
  55. };
  56. function play(millis){
  57. requestAnimationFrame(play);
  58. // now = Date.now();
  59. // delta = now - then;
  60. //
  61. // if(delta > interval){
  62. // then = now -(delta % interval);
  63. // }
  64. }
  65. init();
  66. });