romo-av 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,12 @@
1
- $.fn.romoVideo = function() {
2
- return $.map(this, function(element) {
3
- return new RomoVideo(element);
4
- });
5
- }
6
-
7
- var RomoVideo = function(element) {
8
- this.elem = $(element);
9
- this.videoObj = this.elem[0];
10
-
11
- this._bindFullscreen();
12
- this._bindVideo();
1
+ var RomoVideo = RomoComponent(function(elem) {
2
+ this.elem = elem;
3
+ this.videoObj = this.elem;
13
4
 
14
5
  this.doInit();
15
- this._loadState();
16
-
17
- this.durationTime = undefined;
18
- this.durationFrames = undefined;
19
- this.elem.on('loadedmetadata', $.proxy(function(e) {
20
- this.durationTime = this.getDurationTime();
21
- this.durationFrames = this.getDurationFrames();
22
- }, this));
6
+ this._bindElem()
23
7
 
24
- this.elem.trigger('video:ready', [this.video, this]);
25
- }
26
-
27
- RomoVideo.prototype.doInit = function() {
28
- // override as needed
29
- }
8
+ Romo.trigger(this.elem, 'romoVideo:ready', [this.videoObj, this]);
9
+ });
30
10
 
31
11
  // Playback methods
32
12
 
@@ -76,33 +56,33 @@ RomoVideo.prototype.doModPlaybackByPercent = function(percent) {
76
56
 
77
57
  RomoVideo.prototype.doMute = function() {
78
58
  this.videoObj.muted = true;
79
- this.elem.trigger('video:volumechange', [this.videoObj, this]);
59
+ Romo.trigger(this.elem, 'romoVideo:volumechange', [this.videoObj, this]);
80
60
  }
81
61
 
82
62
  RomoVideo.prototype.doUnmute = function() {
83
63
  this.videoObj.muted = false;
84
- this.elem.trigger('video:volumechange', [this.videoObj, this]);
64
+ Romo.trigger(this.elem, 'romoVideo:volumechange', [this.videoObj, this]);
85
65
  }
86
66
 
87
67
  RomoVideo.prototype.doToggleMute = function() {
88
68
  this.videoObj.muted = !this.videoObj.muted;
89
- this.elem.trigger('video:volumechange', [this.videoObj, this]);
69
+ Romo.trigger(this.elem, 'romoVideo:volumechange', [this.videoObj, this]);
90
70
  }
91
71
 
92
72
  RomoVideo.prototype.getLoop = function() {
93
- return this.elem.prop('loop');
73
+ return this.videoObj.loop;
94
74
  }
95
75
 
96
76
  RomoVideo.prototype.doLoop = function() {
97
- this.elem.prop('loop', true);
98
- this.elem.trigger('video:loop', [this.videoObj, this]);
99
- this.elem.trigger('video:loopChange', [true, this.videoObj, this]);
77
+ this.videoObj.loop = true;
78
+ Romo.trigger(this.elem, 'romoVideo:loop', [this.videoObj, this]);
79
+ Romo.trigger(this.elem, 'romoVideo:loopChange', [true, this.videoObj, this]);
100
80
  }
101
81
 
102
82
  RomoVideo.prototype.doNoLoop = function() {
103
- this.elem.prop('loop', false);
104
- this.elem.trigger('video:noloop', [this.videoObj, this]);
105
- this.elem.trigger('video:loopChange', [false, this.videoObj, this]);
83
+ this.videoObj.loop = false;
84
+ Romo.trigger(this.elem, 'romoVideo:noloop', [this.videoObj, this]);
85
+ Romo.trigger(this.elem, 'romoVideo:loopChange', [false, this.videoObj, this]);
106
86
  }
107
87
 
108
88
  RomoVideo.prototype.doToggleLoop = function() {
@@ -304,240 +284,237 @@ RomoVideo.prototype.getVideoFormattedTime = function(seconds) {
304
284
 
305
285
  // private
306
286
 
307
- RomoVideo.prototype._setPlayback = function(newSecondNum) {
308
- var durationTime = this.getDurationTime();
309
- if (newSecondNum > durationTime) {
310
- if (this.elem.prop('loop') === true){
311
- this.videoObj.currentTime = newSecondNum - durationTime;
312
- } else {
313
- this.videoObj.currentTime = durationTime;
314
- }
315
- } else if (newSecondNum < 0) {
316
- if (this.elem.prop('loop') === true){
317
- this.videoObj.currentTime = (durationTime - (0 - newSecondNum));
318
- } else {
319
- this.videoObj.currentTime = 0;
320
- }
321
- } else {
322
- this.videoObj.currentTime = newSecondNum;
323
- }
324
- }
325
-
326
- RomoVideo.prototype._frameNumToSecondNum = function(frameNum) {
327
- return frameNum / this.fps;
328
- }
329
-
330
- RomoVideo.prototype._percentToSecondNum = function(percent) {
331
- return (percent / 100) * this.getDurationTime();
332
- }
333
-
334
- RomoVideo.prototype._setVolume = function(value) {
335
- if (value > 1) {
336
- this.videoObj.volume = 1;
337
- } else if (value < 0) {
338
- this.videoObj.volume = 0;
339
- } else {
340
- this.videoObj.volume = value;
341
- }
342
- this.doUnmute();
343
- }
344
-
345
- RomoVideo.prototype._loadState = function() {
346
- this.fps = this.elem.data('romo-video-fps');
347
- if (this.fps && this.fps > 0) {
348
- this.fpsEnabled = true;
349
- } else {
350
- this.fpsEnabled = false;
351
- }
352
- this.showMs = this.elem.data('romo-video-show-ms');
353
- }
354
-
355
- RomoVideo.prototype._bindFullscreen = function() {
356
- var fullscreenElem = this.elem.closest(this.elem.data('romo-video-fullscreen-elem'));
357
- if (fullscreenElem[0] !== undefined) {
358
- this.fullscreenElem = fullscreenElem;
359
- } else {
360
- this.fullscreenElem = this.elem;
361
- }
362
-
363
- this._browserRequestFullscreen = this._getBrowserRequestFullscreen(this.fullscreenElem);
364
- this._browserExitFullscreen = this._getBrowserExitFullscreen();
365
-
366
- $(document).on('fullscreenchange', $.proxy(this._onDocumentFullscreenChange, this));
367
- $(document).on('mozfullscreenchange', $.proxy(this._onDocumentFullscreenChange, this));
368
- $(document).on('msfullscreenchange', $.proxy(this._onDocumentFullscreenChange, this));
369
- $(document).on('webkitfullscreenchange', $.proxy(this._onDocumentFullscreenChange, this));
370
- }
287
+ RomoVideo.prototype._bindElem = function() {
288
+ this.durationTime = undefined;
289
+ this.durationFrames = undefined;
290
+ Romo.on(this.elem, 'loadedmetadata', Romo.proxy(function(e) {
291
+ this.durationTime = this.getDurationTime();
292
+ this.durationFrames = this.getDurationFrames();
293
+ }, this));
371
294
 
372
- RomoVideo.prototype._bindVideo = function() {
295
+ this._bindFullscreen();
373
296
  this._bindVideoElemEvents();
374
297
  this._bindVideoTriggerEvents();
298
+ this._loadState();
375
299
  }
376
300
 
377
301
  RomoVideo.prototype._bindVideoElemEvents = function() {
378
302
  // playback events
379
303
 
380
- this.elem.on('play', $.proxy(function(e) {
381
- this.elem.trigger('video:play', [this.videoObj, this]);
304
+ Romo.on(this.elem, 'play', Romo.proxy(function(e) {
305
+ Romo.trigger(this.elem, 'romoVideo:play', [this.videoObj, this]);
382
306
  }, this));
383
- this.elem.on('pause', $.proxy(function(e) {
384
- this.elem.trigger('video:pause', [this.videoObj, this]);
307
+ Romo.on(this.elem, 'pause', Romo.proxy(function(e) {
308
+ Romo.trigger(this.elem, 'romoVideo:pause', [this.videoObj, this]);
385
309
  }, this));
386
310
 
387
311
  // state events
388
312
 
389
- this.elem.on('playing', $.proxy(function(e) {
390
- this.elem.trigger('video:playing', [this.videoObj, this]);
313
+ Romo.on(this.elem, 'playing', Romo.proxy(function(e) {
314
+ Romo.trigger(this.elem, 'romoVideo:playing', [this.videoObj, this]);
391
315
  }, this));
392
- this.elem.on('waiting', $.proxy(function(e) {
393
- this.elem.trigger('video:waiting', [this.videoObj, this]);
316
+ Romo.on(this.elem, 'waiting', Romo.proxy(function(e) {
317
+ Romo.trigger(this.elem, 'romoVideo:waiting', [this.videoObj, this]);
394
318
  }, this));
395
- this.elem.on('ended', $.proxy(function(e) {
396
- this.elem.trigger('video:ended', [this.videoObj, this]);
319
+ Romo.on(this.elem, 'ended', Romo.proxy(function(e) {
320
+ Romo.trigger(this.elem, 'romoVideo:ended', [this.videoObj, this]);
397
321
  }, this));
398
- this.elem.on('emptied', $.proxy(function(e) {
399
- this.elem.trigger('video:emptied', [this.videoObj, this]);
322
+ Romo.on(this.elem, 'emptied', Romo.proxy(function(e) {
323
+ Romo.trigger(this.elem, 'romoVideo:emptied', [this.videoObj, this]);
400
324
  }, this));
401
- this.elem.on('error', $.proxy(function(e) {
402
- this.elem.trigger('video:error', [this.videoObj, this]);
325
+ Romo.on(this.elem, 'error', Romo.proxy(function(e) {
326
+ Romo.trigger(this.elem, 'romoVideo:error', [this.videoObj, this]);
403
327
  }, this));
404
- this.elem.on('stalled', $.proxy(function(e) {
405
- this.elem.trigger('video:stalled', [this.videoObj, this]);
328
+ Romo.on(this.elem, 'stalled', Romo.proxy(function(e) {
329
+ Romo.trigger(this.elem, 'romoVideo:stalled', [this.videoObj, this]);
406
330
  }, this));
407
- this.elem.on('suspend', $.proxy(function(e) {
408
- this.elem.trigger('video:suspend', [this.videoObj, this]);
331
+ Romo.on(this.elem, 'suspend', Romo.proxy(function(e) {
332
+ Romo.trigger(this.elem, 'romoVideo:suspend', [this.videoObj, this]);
409
333
  }, this));
410
334
 
411
335
  // status events
412
336
 
413
- this.elem.on('progress', $.proxy(function(e) {
414
- this.elem.trigger('video:progress', [this.videoObj, this]);
337
+ Romo.on(this.elem, 'progress', Romo.proxy(function(e) {
338
+ Romo.trigger(this.elem, 'romoVideo:progress', [this.videoObj, this]);
415
339
  }, this));
416
- this.elem.on('timeupdate', $.proxy(function(e) {
417
- this.elem.trigger('video:timeupdate', [this.videoObj, this]);
340
+ Romo.on(this.elem, 'timeupdate', Romo.proxy(function(e) {
341
+ Romo.trigger(this.elem, 'romoVideo:timeupdate', [this.videoObj, this]);
418
342
  }, this));
419
343
 
420
344
  // settings events
421
345
 
422
- this.elem.on('volumechange', $.proxy(function(e) {
423
- this.elem.trigger('video:volumechange', [this.videoObj, this]);
346
+ Romo.on(this.elem, 'volumechange', Romo.proxy(function(e) {
347
+ Romo.trigger(this.elem, 'romoVideo:volumechange', [this.videoObj, this]);
424
348
  }, this));
425
- this.elem.on('durationchange', $.proxy(function(e) {
426
- this.elem.trigger('video:durationchange', [this.videoObj, this]);
349
+ Romo.on(this.elem, 'durationchange', Romo.proxy(function(e) {
350
+ Romo.trigger(this.elem, 'romoVideo:durationchange', [this.videoObj, this]);
427
351
  }, this));
428
- this.elem.on('ratechange', $.proxy(function(e) {
429
- this.elem.trigger('video:ratechange', [this.videoObj, this]);
352
+ Romo.on(this.elem, 'ratechange', Romo.proxy(function(e) {
353
+ Romo.trigger(this.elem, 'romoVideo:ratechange', [this.videoObj, this]);
430
354
  }, this));
431
355
 
432
356
  // load events
433
357
 
434
- this.elem.on('loadstart', $.proxy(function(e) {
435
- this.elem.trigger('video:loadstart', [this.videoObj, this]);
358
+ Romo.on(this.elem, 'loadstart', Romo.proxy(function(e) {
359
+ Romo.trigger(this.elem, 'romoVideo:loadstart', [this.videoObj, this]);
436
360
  }, this));
437
- this.elem.on('loadedmetadata', $.proxy(function(e) {
438
- this.elem.trigger('video:loadedmetadata', [this.videoObj, this]);
361
+ Romo.on(this.elem, 'loadedmetadata', Romo.proxy(function(e) {
362
+ Romo.trigger(this.elem, 'romoVideo:loadedmetadata', [this.videoObj, this]);
439
363
  }, this));
440
- this.elem.on('loadeddata', $.proxy(function(e) {
441
- this.elem.trigger('video:loadeddata', [this.videoObj, this]);
364
+ Romo.on(this.elem, 'loadeddata', Romo.proxy(function(e) {
365
+ Romo.trigger(this.elem, 'romoVideo:loadeddata', [this.videoObj, this]);
442
366
  }, this));
443
- this.elem.on('canplay', $.proxy(function(e) {
444
- this.elem.trigger('video:canplay', [this.videoObj, this]);
367
+ Romo.on(this.elem, 'canplay', Romo.proxy(function(e) {
368
+ Romo.trigger(this.elem, 'romoVideo:canplay', [this.videoObj, this]);
445
369
  }, this));
446
- this.elem.on('canplaythrough', $.proxy(function(e) {
447
- this.elem.trigger('video:canplaythrough', [this.videoObj, this]);
370
+ Romo.on(this.elem, 'canplaythrough', Romo.proxy(function(e) {
371
+ Romo.trigger(this.elem, 'romoVideo:canplaythrough', [this.videoObj, this]);
448
372
  }, this));
449
373
  }
450
374
 
451
375
  RomoVideo.prototype._bindVideoTriggerEvents = function() {
452
376
  // playback triggers
453
377
 
454
- this.elem.on('video:triggerPlay', $.proxy(function(e) {
378
+ Romo.on(this.elem, 'romoVideo:triggerPlay', Romo.proxy(function(e) {
455
379
  this.doPlay(); return false;
456
380
  }, this));
457
- this.elem.on('video:triggerPause', $.proxy(function(e) {
381
+ Romo.on(this.elem, 'romoVideo:triggerPause', Romo.proxy(function(e) {
458
382
  this.doPause(); return false;
459
383
  }, this));
460
- this.elem.on('video:triggerTogglePlay', $.proxy(function(e) {
384
+ Romo.on(this.elem, 'romoVideo:triggerTogglePlay', Romo.proxy(function(e) {
461
385
  this.doTogglePlay(); return false;
462
386
  }, this));
463
- this.elem.on('video:triggerSetPlaybackToTime', $.proxy(function(e, secondNum) {
387
+ Romo.on(this.elem, 'romoVideo:triggerSetPlaybackToTime', Romo.proxy(function(e, secondNum) {
464
388
  this.doSetPlaybackToTime(secondNum); return false;
465
389
  }, this));
466
- this.elem.on('video:triggerSetPlaybackToFrame', $.proxy(function(e, frameNum) {
390
+ Romo.on(this.elem, 'romoVideo:triggerSetPlaybackToFrame', Romo.proxy(function(e, frameNum) {
467
391
  this.doSetPlaybackToFrame(frameNum); return false;
468
392
  }, this));
469
- this.elem.on('video:triggerSetPlaybackToPercent', $.proxy(function(e, percent) {
393
+ Romo.on(this.elem, 'romoVideo:triggerSetPlaybackToPercent', Romo.proxy(function(e, percent) {
470
394
  this.doSetPlaybackToPercent(percent); return false;
471
395
  }, this));
472
- this.elem.on('video:triggerModPlaybackByTime', $.proxy(function(e, secondsCount) {
396
+ Romo.on(this.elem, 'romoVideo:triggerModPlaybackByTime', Romo.proxy(function(e, secondsCount) {
473
397
  this.doModPlaybackByTime(secondsCount); return false;
474
398
  }, this));
475
- this.elem.on('video:triggerModPlaybackByFrames', $.proxy(function(e, frameCount) {
399
+ Romo.on(this.elem, 'romoVideo:triggerModPlaybackByFrames', Romo.proxy(function(e, frameCount) {
476
400
  this.doModPlaybackByFrames(frameCount); return false;
477
401
  }, this));
478
- this.elem.on('video:triggerModPlaybackByPercent', $.proxy(function(e, percent) {
402
+ Romo.on(this.elem, 'romoVideo:triggerModPlaybackByPercent', Romo.proxy(function(e, percent) {
479
403
  this.doModPlaybackByPercent(percent); return false;
480
404
  }, this));
481
405
 
482
406
  // settings triggers
483
407
 
484
- this.elem.on('video:triggerMute', $.proxy(function(e) {
408
+ Romo.on(this.elem, 'romoVideo:triggerMute', Romo.proxy(function(e) {
485
409
  this.doMute(); return false;
486
410
  }, this));
487
- this.elem.on('video:triggerUnmute', $.proxy(function(e) {
411
+ Romo.on(this.elem, 'romoVideo:triggerUnmute', Romo.proxy(function(e) {
488
412
  this.doUnmute(); return false;
489
413
  }, this));
490
- this.elem.on('video:triggerToggleMute', $.proxy(function(e) {
414
+ Romo.on(this.elem, 'romoVideo:triggerToggleMute', Romo.proxy(function(e) {
491
415
  this.doToggleMute(); return false;
492
416
  }, this));
493
- this.elem.on('video:triggerSetVolumeToPercent', $.proxy(function(e, percent) {
417
+ Romo.on(this.elem, 'romoVideo:triggerSetVolumeToPercent', Romo.proxy(function(e, percent) {
494
418
  this.doSetVolumeToPercent(percent); return false;
495
419
  }, this));
496
- this.elem.on('video:triggerModVolumeByPercent', $.proxy(function(e, percent) {
420
+ Romo.on(this.elem, 'romoVideo:triggerModVolumeByPercent', Romo.proxy(function(e, percent) {
497
421
  this.doModVolumeByPercent(percent); return false;
498
422
  }, this));
499
- this.elem.on('video:triggerSetPlaybackRate', $.proxy(function(e, rate) {
423
+ Romo.on(this.elem, 'romoVideo:triggerSetPlaybackRate', Romo.proxy(function(e, rate) {
500
424
  this.doSetPlaybackToRate(rate); return false;
501
425
  }, this));
502
- this.elem.on('video:triggerModPlaybackRate', $.proxy(function(e, rate) {
426
+ Romo.on(this.elem, 'romoVideo:triggerModPlaybackRate', Romo.proxy(function(e, rate) {
503
427
  this.doModPlaybackByRate(rate); return false;
504
428
  }, this));
505
429
 
506
430
  // fullscreen triggers
507
431
 
508
- this.elem.on('video:triggerEnterFullscreen', $.proxy(function(e) {
432
+ Romo.on(this.elem, 'romoVideo:triggerEnterFullscreen', Romo.proxy(function(e) {
509
433
  this.doEnterFullscreen(); return false;
510
434
  }, this));
511
- this.elem.on('video:triggerExitFullscreen', $.proxy(function(e) {
435
+ Romo.on(this.elem, 'romoVideo:triggerExitFullscreen', Romo.proxy(function(e) {
512
436
  this.doExitFullscreen(); return false;
513
437
  }, this));
514
- this.elem.on('video:triggerToggleFullscreen', $.proxy(function(e) {
438
+ Romo.on(this.elem, 'romoVideo:triggerToggleFullscreen', Romo.proxy(function(e) {
515
439
  this.doToggleFullscreen(); return false;
516
440
  }, this));
517
441
 
518
442
  // load triggers
519
443
 
520
- this.elem.on('video:triggerLoad', $.proxy(function(e) {
444
+ Romo.on(this.elem, 'romoVideo:triggerLoad', Romo.proxy(function(e) {
521
445
  this.doLoad(); return false;
522
446
  }, this));
523
- this.elem.on('video:triggerModSource', $.proxy(function(e, source) {
447
+ Romo.on(this.elem, 'romoVideo:triggerModSource', Romo.proxy(function(e, source) {
524
448
  this.doModSource(source); return false;
525
449
  }, this));
526
450
 
527
451
  }
528
452
 
529
- RomoVideo.prototype._onDocumentFullscreenChange = function(e) {
530
- if (this._getCurrentFullscreenElem() === this.fullscreenElem[0]) {
531
- this.fullScreen = true;
532
- this.elem.trigger('video:enterFullscreen', [this.videoObj, this]);
533
- this.elem.trigger('video:fullscreenChange', [this.videoObj, this]);
534
- } else if (this.fullScreen === true) {
535
- this.fullScreen = false;
536
- this.elem.trigger('video:exitFullscreen', [this.videoObj, this]);
537
- this.elem.trigger('video:fullscreenChange', [this.videoObj, this]);
453
+ RomoVideo.prototype._bindFullscreen = function() {
454
+ var fullscreenElem = Romo.closest(this.elem, Romo.data(this.elem, 'romo-video-fullscreen-elem'));
455
+ if (fullscreenElem !== undefined) {
456
+ this.fullscreenElem = fullscreenElem;
457
+ } else {
458
+ this.fullscreenElem = this.elem;
459
+ }
460
+
461
+ this._browserRequestFullscreen = this._getBrowserRequestFullscreen(this.fullscreenElem);
462
+ this._browserExitFullscreen = this._getBrowserExitFullscreen();
463
+
464
+ Romo.on(document, 'fullscreenchange', Romo.proxy(this._onDocumentFullscreenChange, this));
465
+ Romo.on(document, 'mozfullscreenchange', Romo.proxy(this._onDocumentFullscreenChange, this));
466
+ Romo.on(document, 'msfullscreenchange', Romo.proxy(this._onDocumentFullscreenChange, this));
467
+ Romo.on(document, 'webkitfullscreenchange', Romo.proxy(this._onDocumentFullscreenChange, this));
468
+ }
469
+
470
+ RomoVideo.prototype._loadState = function() {
471
+ this.fps = Romo.data(this.elem, 'romo-video-fps');
472
+ if (this.fps && this.fps > 0) {
473
+ this.fpsEnabled = true;
474
+ } else {
475
+ this.fpsEnabled = false;
476
+ }
477
+ this.showMs = Romo.data(this.elem, 'romo-video-show-ms');
478
+ }
479
+
480
+ RomoVideo.prototype._setPlayback = function(newSecondNum) {
481
+ var durationTime = this.getDurationTime();
482
+ if (newSecondNum > durationTime) {
483
+ if (this.getLoop() === true){
484
+ this.videoObj.currentTime = newSecondNum - durationTime;
485
+ } else {
486
+ this.videoObj.currentTime = durationTime;
487
+ }
488
+ } else if (newSecondNum < 0) {
489
+ if (this.getLoop() === true){
490
+ this.videoObj.currentTime = (durationTime - (0 - newSecondNum));
491
+ } else {
492
+ this.videoObj.currentTime = 0;
493
+ }
494
+ } else {
495
+ this.videoObj.currentTime = newSecondNum;
538
496
  }
539
497
  }
540
498
 
499
+ RomoVideo.prototype._frameNumToSecondNum = function(frameNum) {
500
+ return frameNum / this.fps;
501
+ }
502
+
503
+ RomoVideo.prototype._percentToSecondNum = function(percent) {
504
+ return (percent / 100) * this.getDurationTime();
505
+ }
506
+
507
+ RomoVideo.prototype._setVolume = function(value) {
508
+ if (value > 1) {
509
+ this.videoObj.volume = 1;
510
+ } else if (value < 0) {
511
+ this.videoObj.volume = 0;
512
+ } else {
513
+ this.videoObj.volume = value;
514
+ }
515
+ this.doUnmute();
516
+ }
517
+
541
518
  RomoVideo.prototype._getCurrentFullscreenElem = function() {
542
519
  return document.fullscreenElement ||
543
520
  document.mozFullScreenElement ||
@@ -547,7 +524,7 @@ RomoVideo.prototype._getCurrentFullscreenElem = function() {
547
524
 
548
525
  RomoVideo.prototype._requestFullscreen = function() {
549
526
  if (this._canFullscreen()) {
550
- this._browserRequestFullscreen.apply(this.fullscreenElem[0]);
527
+ this._browserRequestFullscreen.apply(this.fullscreenElem);
551
528
  } else {
552
529
  return false;
553
530
  }
@@ -582,14 +559,14 @@ RomoVideo.prototype._canFullscreen = function() {
582
559
  RomoVideo.prototype._getBrowserRequestFullscreen = function(fullscreenElem) {
583
560
  // look for the browser-specific requestFullscreen function and return it
584
561
 
585
- if (fullscreenElem[0].requestFullscreen) {
586
- return fullscreenElem[0].requestFullscreen;
587
- } else if (fullscreenElem[0].mozRequestFullScreen) {
588
- return fullscreenElem[0].mozRequestFullScreen;
589
- } else if (fullscreenElem[0].msRequestFullscreen) {
590
- return fullscreenElem[0].msRequestFullscreen;
591
- } else if (fullscreenElem[0].webkitRequestFullscreen) {
592
- return this.fullscreenElem[0].webkitRequestFullscreen;
562
+ if (fullscreenElem.requestFullscreen) {
563
+ return fullscreenElem.requestFullscreen;
564
+ } else if (fullscreenElem.mozRequestFullScreen) {
565
+ return fullscreenElem.mozRequestFullScreen;
566
+ } else if (fullscreenElem.msRequestFullscreen) {
567
+ return fullscreenElem.msRequestFullscreen;
568
+ } else if (fullscreenElem.webkitRequestFullscreen) {
569
+ return this.fullscreenElem.webkitRequestFullscreen;
593
570
  } else {
594
571
  return undefined;
595
572
  }
@@ -614,6 +591,20 @@ RomoVideo.prototype._getBrowserExitFullscreen = function(fullscreenElem) {
614
591
  }
615
592
  }
616
593
 
617
- Romo.onInitUI(function(e) {
618
- Romo.initUIElems(e, '[data-romo-video-auto="true"]').romoVideo();
619
- });
594
+ // event functions
595
+
596
+ RomoVideo.prototype.romoEvFn._onDocumentFullscreenChange = function(e) {
597
+ if (this._getCurrentFullscreenElem() === this.fullscreenElem) {
598
+ this.fullScreen = true;
599
+ Romo.trigger(this.elem, 'romoVideo:enterFullscreen', [this.videoObj, this]);
600
+ Romo.trigger(this.elem, 'romoVideo:fullscreenChange', [this.videoObj, this]);
601
+ } else if (this.fullScreen === true) {
602
+ this.fullScreen = false;
603
+ Romo.trigger(this.elem, 'romoVideo:exitFullscreen', [this.videoObj, this]);
604
+ Romo.trigger(this.elem, 'romoVideo:fullscreenChange', [this.videoObj, this]);
605
+ }
606
+ }
607
+
608
+ // init
609
+
610
+ Romo.addElemsInitSelector('[data-romo-video-auto="true"]', RomoVideo);