romo-av 0.1.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.
@@ -0,0 +1,619 @@
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();
13
+
14
+ 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));
23
+
24
+ this.elem.trigger('video:ready', [this.video, this]);
25
+ }
26
+
27
+ RomoVideo.prototype.doInit = function() {
28
+ // override as needed
29
+ }
30
+
31
+ // Playback methods
32
+
33
+ RomoVideo.prototype.doPlay = function() {
34
+ this.videoObj.play();
35
+ }
36
+
37
+ RomoVideo.prototype.doPause = function() {
38
+ this.videoObj.pause();
39
+ }
40
+
41
+ RomoVideo.prototype.doTogglePlay = function() {
42
+ if (this.videoObj.paused) {
43
+ this.videoObj.play();
44
+ } else {
45
+ this.videoObj.pause();
46
+ }
47
+ }
48
+
49
+ RomoVideo.prototype.doSetPlaybackToTime = function(secondNum) {
50
+ this._setPlayback(secondNum);
51
+ }
52
+
53
+ RomoVideo.prototype.doSetPlaybackToFrame = function(frameNum) {
54
+ if(this.fpsEnabled !== true){ return; }
55
+ this._setPlayback(this._frameNumToSecondNum(frameNum));
56
+ }
57
+
58
+ RomoVideo.prototype.doSetPlaybackToPercent = function(percent) {
59
+ this._setPlayback(this._percentToSecondNum(percent));
60
+ }
61
+
62
+ RomoVideo.prototype.doModPlaybackByTime = function(secondsCount) {
63
+ this._setPlayback(this.videoObj.currentTime + secondsCount);
64
+ }
65
+
66
+ RomoVideo.prototype.doModPlaybackByFrames = function(frameCount) {
67
+ if(this.fpsEnabled !== true){ return; }
68
+ this._setPlayback(this.videoObj.currentTime + this._frameNumToSecondNum(frameCount));
69
+ }
70
+
71
+ RomoVideo.prototype.doModPlaybackByPercent = function(percent) {
72
+ this._setPlayback(this.videoObj.currentTime + this._percentToSecondNum(percent));
73
+ }
74
+
75
+ // Settings methods
76
+
77
+ RomoVideo.prototype.doMute = function() {
78
+ this.videoObj.muted = true;
79
+ this.elem.trigger('video:volumechange', [this.videoObj, this]);
80
+ }
81
+
82
+ RomoVideo.prototype.doUnmute = function() {
83
+ this.videoObj.muted = false;
84
+ this.elem.trigger('video:volumechange', [this.videoObj, this]);
85
+ }
86
+
87
+ RomoVideo.prototype.doToggleMute = function() {
88
+ this.videoObj.muted = !this.videoObj.muted;
89
+ this.elem.trigger('video:volumechange', [this.videoObj, this]);
90
+ }
91
+
92
+ RomoVideo.prototype.getLoop = function() {
93
+ return this.elem.prop('loop');
94
+ }
95
+
96
+ 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]);
100
+ }
101
+
102
+ 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]);
106
+ }
107
+
108
+ RomoVideo.prototype.doToggleLoop = function() {
109
+ if (this.getLoop() !== true) {
110
+ this.doLoop();
111
+ } else {
112
+ this.doNoLoop();
113
+ }
114
+ }
115
+
116
+ RomoVideo.prototype.doSetVolumeToPercent = function(percent) {
117
+ this._setVolume(percent / 100);
118
+ }
119
+
120
+ RomoVideo.prototype.doModVolumeByPercent = function(percent) {
121
+ this._setVolume(this.videoObj.volume + (percent / 100));
122
+ }
123
+
124
+ RomoVideo.prototype.doSetPlaybackToRate = function(rate) {
125
+ this.videoObj.playbackRate = rate;
126
+ }
127
+
128
+ RomoVideo.prototype.doModPlaybackByRate = function(rate) {
129
+ this.videoObj.playbackRate = this.videoObj.playbackRate + rate;
130
+ }
131
+
132
+ // Fullscreen methods
133
+
134
+ RomoVideo.prototype.doEnterFullscreen = function() {
135
+ this._requestFullscreen();
136
+ }
137
+
138
+ RomoVideo.prototype.doExitFullscreen = function() {
139
+ this._exitFullscreen();
140
+ }
141
+
142
+ RomoVideo.prototype.doToggleFullscreen = function() {
143
+ if (this.fullScreen === true) {
144
+ this._exitFullscreen();
145
+ } else {
146
+ this._requestFullscreen();
147
+ }
148
+ }
149
+
150
+ // Status methods
151
+
152
+ RomoVideo.prototype.getPlaybackTime = function() {
153
+ return this.videoObj.currentTime;
154
+ }
155
+
156
+ RomoVideo.prototype.getPlaybackFrame = function() {
157
+ return this.getVideoTimeInFrames(this.getPlaybackTime());
158
+ }
159
+
160
+ RomoVideo.prototype.getPlaybackPercent = function() {
161
+ return this.getVideoTimeInPercent(this.getPlaybackTime());
162
+ }
163
+
164
+ RomoVideo.prototype.getDurationTime = function() {
165
+ if (this.durationTime !== undefined) {
166
+ return this.durationTime;
167
+ } else if (isNaN(parseInt(this.videoObj.duration)) === true) {
168
+ return 0.0;
169
+ } else {
170
+ return this.videoObj.duration;
171
+ }
172
+ }
173
+
174
+ RomoVideo.prototype.getDurationFrames = function() {
175
+ if (this.durationFrames !== undefined) {
176
+ return this.durationFrames;
177
+ } else if (this.fpsEnabled !== true) {
178
+ return 0;
179
+ } else {
180
+ return Math.round(this.getDurationTime() * this.fps);
181
+ }
182
+ }
183
+
184
+ RomoVideo.prototype.getDurationPercent = function() {
185
+ return 100;
186
+ }
187
+
188
+ RomoVideo.prototype.getTotalBufferedTime = function() {
189
+ return this.getTotalBufferedTuples().reduce(function(prev, curr) {
190
+ return prev + (curr[1] - curr[0]);
191
+ }, 0.0);
192
+ }
193
+
194
+ RomoVideo.prototype.getTotalBufferedFrames = function() {
195
+ return this.getVideoTimeInFrames(this.getTotalBufferedTime());
196
+ }
197
+
198
+ RomoVideo.prototype.getTotalBufferedPercent = function() {
199
+ return this.getVideoTimeInPercent(this.getTotalBufferedTime());
200
+ }
201
+
202
+ RomoVideo.prototype.getTotalBufferedTuples = function() {
203
+ var tuples = [];
204
+ var buffered = this.videoObj.buffered;
205
+ for (i = 0; i < buffered.length; i++) {
206
+ tuples.push([buffered.start(i), buffered.end(i)]);
207
+ }
208
+ return tuples;
209
+ }
210
+
211
+ RomoVideo.prototype.getVolumeValue = function() {
212
+ if (this.videoObj.muted === true) {
213
+ return 0;
214
+ } else {
215
+ return this.videoObj.volume;
216
+ }
217
+ }
218
+
219
+ RomoVideo.prototype.getVolumePercent = function() {
220
+ return this.getVolumeValue() * 100;
221
+ }
222
+
223
+ RomoVideo.prototype.getVolumeMuted = function() {
224
+ return this.videoObj.muted === true || this.getVolumePercent() === 0;
225
+ }
226
+
227
+ // Load methods
228
+
229
+ RomoVideo.prototype.doLoad = function() {
230
+ this.doPause();
231
+ this._loadState();
232
+ this.videoObj.load();
233
+ }
234
+
235
+ RomoVideo.prototype.doModSource = function(source) {
236
+ this.videoObj.src = source;
237
+
238
+ this.durationTime = undefined;
239
+ this.durationFrames = undefined;
240
+ }
241
+
242
+ // Helper methods
243
+
244
+ RomoVideo.prototype.getVideoTimeInFrames = function(time) {
245
+ return this.getVideoPercentInFrames(this.getVideoTimeInPercent(time));
246
+ }
247
+ RomoVideo.prototype.getVideoTimeInPercent = function(time) {
248
+ if (this.getDurationTime() === 0.0) {
249
+ return 0;
250
+ } else {
251
+ return (time / this.getDurationTime()) * 100;
252
+ }
253
+ }
254
+ RomoVideo.prototype.getVideoFramesInTime = function(frameCount) {
255
+ return this.getVideoPercentInTime(this.getVideoFramesInPercent(frameCount));
256
+ }
257
+ RomoVideo.prototype.getVideoFramesInPercent = function(frameCount) {
258
+ if (this.fpsEnabled !== true) {
259
+ return 0;
260
+ } else {
261
+ return (frameCount / this.getDurationFrames()) * 100;
262
+ }
263
+ }
264
+ RomoVideo.prototype.getVideoPercentInTime = function(percent) {
265
+ return (percent / 100) * this.getDurationTime();
266
+ }
267
+ RomoVideo.prototype.getVideoPercentInFrames = function(percent) {
268
+ if (this.fpsEnabled !== true) {
269
+ return 0;
270
+ } else {
271
+ var framesCalc = (percent / 100) * this.getDurationFrames();
272
+ if (framesCalc >= 0) {
273
+ return Math.ceil(framesCalc);
274
+ } else {
275
+ return Math.floor(framesCalc);
276
+ }
277
+ }
278
+ }
279
+
280
+ RomoVideo.prototype.getVideoFormattedTime = function(seconds) {
281
+ if (isNaN(parseInt(seconds)) === true || seconds === 0) {
282
+ if (this.showMs !== false) {
283
+ return '00:00.000';
284
+ } else {
285
+ return '00:00';
286
+ }
287
+ }
288
+
289
+ var abs = Math.abs(seconds);
290
+ var hrs = Math.floor(abs / 3600);
291
+ var mins = Math.floor((abs - (hrs * 3600)) / 60);
292
+ var secs = Math.floor(abs % 60);
293
+
294
+ var t = (hrs ? hrs + ':' : '') +
295
+ (mins < 10 ? '0' : '') + mins + ':' +
296
+ (secs < 10 ? '0' : '') + secs;
297
+ if (this.showMs !== false) {
298
+ t += (abs - Math.floor(abs)).toFixed(3).slice(1);
299
+ }
300
+
301
+ if (seconds > 0){ return t; }
302
+ else{ return '-'+t; }
303
+ }
304
+
305
+ // private
306
+
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
+ }
371
+
372
+ RomoVideo.prototype._bindVideo = function() {
373
+ this._bindVideoElemEvents();
374
+ this._bindVideoTriggerEvents();
375
+ }
376
+
377
+ RomoVideo.prototype._bindVideoElemEvents = function() {
378
+ // playback events
379
+
380
+ this.elem.on('play', $.proxy(function(e) {
381
+ this.elem.trigger('video:play', [this.videoObj, this]);
382
+ }, this));
383
+ this.elem.on('pause', $.proxy(function(e) {
384
+ this.elem.trigger('video:pause', [this.videoObj, this]);
385
+ }, this));
386
+
387
+ // state events
388
+
389
+ this.elem.on('playing', $.proxy(function(e) {
390
+ this.elem.trigger('video:playing', [this.videoObj, this]);
391
+ }, this));
392
+ this.elem.on('waiting', $.proxy(function(e) {
393
+ this.elem.trigger('video:waiting', [this.videoObj, this]);
394
+ }, this));
395
+ this.elem.on('ended', $.proxy(function(e) {
396
+ this.elem.trigger('video:ended', [this.videoObj, this]);
397
+ }, this));
398
+ this.elem.on('emptied', $.proxy(function(e) {
399
+ this.elem.trigger('video:emptied', [this.videoObj, this]);
400
+ }, this));
401
+ this.elem.on('error', $.proxy(function(e) {
402
+ this.elem.trigger('video:error', [this.videoObj, this]);
403
+ }, this));
404
+ this.elem.on('stalled', $.proxy(function(e) {
405
+ this.elem.trigger('video:stalled', [this.videoObj, this]);
406
+ }, this));
407
+ this.elem.on('suspend', $.proxy(function(e) {
408
+ this.elem.trigger('video:suspend', [this.videoObj, this]);
409
+ }, this));
410
+
411
+ // status events
412
+
413
+ this.elem.on('progress', $.proxy(function(e) {
414
+ this.elem.trigger('video:progress', [this.videoObj, this]);
415
+ }, this));
416
+ this.elem.on('timeupdate', $.proxy(function(e) {
417
+ this.elem.trigger('video:timeupdate', [this.videoObj, this]);
418
+ }, this));
419
+
420
+ // settings events
421
+
422
+ this.elem.on('volumechange', $.proxy(function(e) {
423
+ this.elem.trigger('video:volumechange', [this.videoObj, this]);
424
+ }, this));
425
+ this.elem.on('durationchange', $.proxy(function(e) {
426
+ this.elem.trigger('video:durationchange', [this.videoObj, this]);
427
+ }, this));
428
+ this.elem.on('ratechange', $.proxy(function(e) {
429
+ this.elem.trigger('video:ratechange', [this.videoObj, this]);
430
+ }, this));
431
+
432
+ // load events
433
+
434
+ this.elem.on('loadstart', $.proxy(function(e) {
435
+ this.elem.trigger('video:loadstart', [this.videoObj, this]);
436
+ }, this));
437
+ this.elem.on('loadedmetadata', $.proxy(function(e) {
438
+ this.elem.trigger('video:loadedmetadata', [this.videoObj, this]);
439
+ }, this));
440
+ this.elem.on('loadeddata', $.proxy(function(e) {
441
+ this.elem.trigger('video:loadeddata', [this.videoObj, this]);
442
+ }, this));
443
+ this.elem.on('canplay', $.proxy(function(e) {
444
+ this.elem.trigger('video:canplay', [this.videoObj, this]);
445
+ }, this));
446
+ this.elem.on('canplaythrough', $.proxy(function(e) {
447
+ this.elem.trigger('video:canplaythrough', [this.videoObj, this]);
448
+ }, this));
449
+ }
450
+
451
+ RomoVideo.prototype._bindVideoTriggerEvents = function() {
452
+ // playback triggers
453
+
454
+ this.elem.on('video:triggerPlay', $.proxy(function(e) {
455
+ this.doPlay(); return false;
456
+ }, this));
457
+ this.elem.on('video:triggerPause', $.proxy(function(e) {
458
+ this.doPause(); return false;
459
+ }, this));
460
+ this.elem.on('video:triggerTogglePlay', $.proxy(function(e) {
461
+ this.doTogglePlay(); return false;
462
+ }, this));
463
+ this.elem.on('video:triggerSetPlaybackToTime', $.proxy(function(e, secondNum) {
464
+ this.doSetPlaybackToTime(secondNum); return false;
465
+ }, this));
466
+ this.elem.on('video:triggerSetPlaybackToFrame', $.proxy(function(e, frameNum) {
467
+ this.doSetPlaybackToFrame(frameNum); return false;
468
+ }, this));
469
+ this.elem.on('video:triggerSetPlaybackToPercent', $.proxy(function(e, percent) {
470
+ this.doSetPlaybackToPercent(percent); return false;
471
+ }, this));
472
+ this.elem.on('video:triggerModPlaybackByTime', $.proxy(function(e, secondsCount) {
473
+ this.doModPlaybackByTime(secondsCount); return false;
474
+ }, this));
475
+ this.elem.on('video:triggerModPlaybackByFrames', $.proxy(function(e, frameCount) {
476
+ this.doModPlaybackByFrames(frameCount); return false;
477
+ }, this));
478
+ this.elem.on('video:triggerModPlaybackByPercent', $.proxy(function(e, percent) {
479
+ this.doModPlaybackByPercent(percent); return false;
480
+ }, this));
481
+
482
+ // settings triggers
483
+
484
+ this.elem.on('video:triggerMute', $.proxy(function(e) {
485
+ this.doMute(); return false;
486
+ }, this));
487
+ this.elem.on('video:triggerUnmute', $.proxy(function(e) {
488
+ this.doUnmute(); return false;
489
+ }, this));
490
+ this.elem.on('video:triggerToggleMute', $.proxy(function(e) {
491
+ this.doToggleMute(); return false;
492
+ }, this));
493
+ this.elem.on('video:triggerSetVolumeToPercent', $.proxy(function(e, percent) {
494
+ this.doSetVolumeToPercent(percent); return false;
495
+ }, this));
496
+ this.elem.on('video:triggerModVolumeByPercent', $.proxy(function(e, percent) {
497
+ this.doModVolumeByPercent(percent); return false;
498
+ }, this));
499
+ this.elem.on('video:triggerSetPlaybackRate', $.proxy(function(e, rate) {
500
+ this.doSetPlaybackToRate(rate); return false;
501
+ }, this));
502
+ this.elem.on('video:triggerModPlaybackRate', $.proxy(function(e, rate) {
503
+ this.doModPlaybackByRate(rate); return false;
504
+ }, this));
505
+
506
+ // fullscreen triggers
507
+
508
+ this.elem.on('video:triggerEnterFullscreen', $.proxy(function(e) {
509
+ this.doEnterFullscreen(); return false;
510
+ }, this));
511
+ this.elem.on('video:triggerExitFullscreen', $.proxy(function(e) {
512
+ this.doExitFullscreen(); return false;
513
+ }, this));
514
+ this.elem.on('video:triggerToggleFullscreen', $.proxy(function(e) {
515
+ this.doToggleFullscreen(); return false;
516
+ }, this));
517
+
518
+ // load triggers
519
+
520
+ this.elem.on('video:triggerLoad', $.proxy(function(e) {
521
+ this.doLoad(); return false;
522
+ }, this));
523
+ this.elem.on('video:triggerModSource', $.proxy(function(e, source) {
524
+ this.doModSource(source); return false;
525
+ }, this));
526
+
527
+ }
528
+
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]);
538
+ }
539
+ }
540
+
541
+ RomoVideo.prototype._getCurrentFullscreenElem = function() {
542
+ return document.fullscreenElement ||
543
+ document.mozFullScreenElement ||
544
+ document.msFullscreenElement ||
545
+ document.webkitFullscreenElement;
546
+ }
547
+
548
+ RomoVideo.prototype._requestFullscreen = function() {
549
+ if (this._canFullscreen()) {
550
+ this._browserRequestFullscreen.apply(this.fullscreenElem[0]);
551
+ } else {
552
+ return false;
553
+ }
554
+ }
555
+
556
+ RomoVideo.prototype._exitFullscreen = function() {
557
+ if (this._canFullscreen()) {
558
+ this._browserExitFullscreen.apply(document);
559
+ } else {
560
+ return false;
561
+ }
562
+ }
563
+
564
+ RomoVideo.prototype._canFullscreen = function() {
565
+ if (this._browserRequestFullscreen === undefined || this._browserExitFullscreen === undefined) {
566
+ return false;
567
+ }
568
+
569
+ if (document.fullscreenEnabled !== undefined) {
570
+ return document.fullscreenEnabled;
571
+ } else if (document.mozFullScreenEnabled !== undefined) {
572
+ return document.mozFullScreenEnabled;
573
+ } else if (document.msFullscreenEnabled !== undefined) {
574
+ return document.msFullscreenEnabled;
575
+ } else if (document.webkitFullscreenEnabled !== undefined) {
576
+ return document.webkitFullscreenEnabled;
577
+ } else {
578
+ return false;
579
+ }
580
+ }
581
+
582
+ RomoVideo.prototype._getBrowserRequestFullscreen = function(fullscreenElem) {
583
+ // look for the browser-specific requestFullscreen function and return it
584
+
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;
593
+ } else {
594
+ return undefined;
595
+ }
596
+ }
597
+
598
+ RomoVideo.prototype._getBrowserExitFullscreen = function(fullscreenElem) {
599
+ // look for the browser-specific exitFullscreen function and return it
600
+ // we use the document because any non-video fullscreen containers will not
601
+ // have this function, calling the document function will exit anything that
602
+ // has been fullscreened
603
+
604
+ if (document.exitFullscreen) {
605
+ return document.exitFullscreen;
606
+ } else if (document.mozCancelFullScreen) {
607
+ return document.mozCancelFullScreen;
608
+ } else if (document.msExitFullscreen) {
609
+ return document.msExitFullscreen;
610
+ } else if (document.webkitExitFullscreen) {
611
+ return document.webkitExitFullscreen;
612
+ } else {
613
+ return undefined;
614
+ }
615
+ }
616
+
617
+ Romo.onInitUI(function(e) {
618
+ Romo.initUIElems(e, '[data-romo-video-auto="true"]').romoVideo();
619
+ });
@@ -0,0 +1,38 @@
1
+ require 'dassets'
2
+ require 'romo-av'
3
+
4
+ module Romo::Av; end
5
+ module Romo::Av::Dassets
6
+
7
+ # This assumes you are using 'js/romo-{audio|video}.js' as part of a larger
8
+ # combination or are loading romo's modal/dropdown js components before
9
+ # loading this combination.
10
+
11
+ def self.configure!
12
+ Dassets.configure do |c|
13
+ c.source Romo::Av.gem_assets_path do |s|
14
+ s.filter{ |paths| paths.reject{ |p| File.basename(p) =~ /^_/ } }
15
+ end
16
+
17
+ # just audio
18
+ c.combination "js/romo-av-audio.js", [
19
+ 'js/romo-av/audio.js'
20
+ ]
21
+
22
+ # just video
23
+ c.combination "js/romo-av-video.js", [
24
+ 'js/romo-av/video.js',
25
+ 'js/romo-av/modal_video.js',
26
+ 'js/romo-av/dropdown_video.js'
27
+ ]
28
+
29
+ # both audio and video
30
+ c.combination "js/romo-av.js", [
31
+ 'js/romo-av-audio.js',
32
+ 'js/romo-av-video.js'
33
+ ]
34
+
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,4 @@
1
+ module Romo; end
2
+ module Romo::Av
3
+ VERSION = "0.1.0"
4
+ end
data/lib/romo-av.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'romo'
2
+ require "romo-av/version"
3
+
4
+ module Romo::Av
5
+
6
+ def self.gem_assets_path; self.gem_path.join('assets'); end
7
+
8
+ private
9
+
10
+ def self.gem_path
11
+ @gem_path ||= Pathname(Gem.loaded_specs['romo-av'].full_gem_path)
12
+ end
13
+
14
+ end
data/log/.gitkeep ADDED
File without changes
data/romo-av.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "romo-av/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "romo-av"
8
+ gem.version = Romo::Av::VERSION
9
+ gem.authors = ["Kelly Redding", "Collin Redding"]
10
+ gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
11
+ gem.description = %q{Romo audio/video components.}
12
+ gem.summary = %q{Romo audio/video components.}
13
+ gem.homepage = "http://github.com/redding/romo-av"
14
+ gem.license = 'MIT'
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency("assert", ["~> 2.15"])
22
+
23
+ gem.add_dependency("romo", ["~> 0.11"])
24
+ end