| author | ymh <ymh.work@gmail.com> |
| Fri, 02 Oct 2015 11:27:17 +0200 | |
| changeset 1068 | 7623f9af9272 |
| parent 1033 | c20df1c080e6 |
| child 1072 | ac1eacb3aa33 |
| permissions | -rw-r--r-- |
| 1033 | 1 |
IriSP.Widgets.Shortcuts = function(player, config) { |
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
3 |
}; |
|
4 |
||
5 |
/** |
|
6 |
* Keyboard shortcuts widget |
|
7 |
* This widgets add global shortcuts for common actions. |
|
8 |
* The default shortcuts are: |
|
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
9 |
* - Control-space for play/pause |
| 1033 | 10 |
* - Control-left for rewind (+shift to go faster) |
11 |
* - Control-right for forward (+shift to go faster) |
|
12 |
*/ |
|
13 |
IriSP.Widgets.Shortcuts.prototype = new IriSP.Widgets.Widget(); |
|
14 |
||
15 |
IriSP.Widgets.Shortcuts.prototype.defaults = { |
|
16 |
// Time increment, in ms, for backward/forward navigation |
|
17 |
time_increment: 2000 |
|
18 |
} |
|
19 |
||
20 |
IriSP.Widgets.Shortcuts.prototype.draw = function() { |
|
21 |
var _this = this; |
|
22 |
|
|
23 |
/* Standard shortcuts */ |
|
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
24 |
Mousetrap.bindGlobal("ctrl+space", function (e) { |
| 1033 | 25 |
e.preventDefault(); |
26 |
if (! _this.media.getPaused()) { |
|
27 |
_this.media.pause(); |
|
28 |
} else { |
|
29 |
_this.media.play(); |
|
30 |
} |
|
31 |
return false; |
|
32 |
}); |
|
33 |
Mousetrap.bindGlobal("ctrl+left", function (e) { |
|
34 |
// Backward |
|
35 |
e.preventDefault(); |
|
36 |
_this.media.setCurrentTime(Math.max(0, _this.media.getCurrentTime() - _this.time_increment)); |
|
37 |
return false; |
|
38 |
}); |
|
39 |
Mousetrap.bindGlobal("ctrl+shift+left", function (e) { |
|
40 |
// Backward |
|
41 |
e.preventDefault(); |
|
42 |
_this.media.setCurrentTime(Math.max(0, _this.media.getCurrentTime() - 5 * _this.time_increment)); |
|
43 |
return false; |
|
44 |
}); |
|
45 |
Mousetrap.bindGlobal("ctrl+right", function (e) { |
|
46 |
// Forward |
|
47 |
e.preventDefault(); |
|
48 |
_this.media.setCurrentTime(Math.min(_this.media.duration, _this.media.getCurrentTime() + _this.time_increment)); |
|
49 |
return false; |
|
50 |
}); |
|
51 |
Mousetrap.bindGlobal("ctrl+shift+right", function (e) { |
|
52 |
// Forward |
|
53 |
e.preventDefault(); |
|
54 |
_this.media.setCurrentTime(Math.min(_this.media.duration, _this.media.getCurrentTime() + 5 * _this.time_increment)); |
|
55 |
return false; |
|
56 |
}); |
|
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
57 |
Mousetrap.bindGlobal("ctrl+a", function (e) { |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
58 |
// Annotate |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
59 |
e.preventDefault(); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
60 |
_this.player.trigger("CreateAnnotation.toggle"); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
61 |
return false; |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1033
diff
changeset
|
62 |
}); |
| 1033 | 63 |
|
64 |
}; |