|
3 | 3 | |
4 | 4 | // HTML5 Media API: |
5 | 5 | // http://www.w3.org/TR/html5/embedded-content-0.html#htmlmediaelement |
| 6 | + // http://dev.w3.org/html5/spec-author-view/video.html |
6 | 7 |
|
7 | 8 | // W3C API Test Page: |
8 | 9 | // http://www.w3.org/2010/05/video/mediaevents.html |
|
26 | 27 | $(document).ready(function () { |
27 | 28 | $('video, audio').each(function (index, element) { |
28 | 29 | if ($(element).data('able-player') !== undefined) { |
29 | | - var includeTranscript = $(element).data('include-transcript'); |
30 | | - if (includeTranscript === undefined || includeTranscript === "") { |
31 | | - // If there are caption tracks and no default provided, include transcript. |
32 | | - if ($(element).find('track[kind="captions"], track[kind="subtitles"]').length > 0) { |
33 | | - includeTranscript = true; |
34 | | - } |
35 | | - } |
36 | | - new AblePlayer($(this), |
37 | | - $(element).data('start-time') || 0, |
38 | | - includeTranscript, |
39 | | - $(element).data('transcript-div'), |
40 | | - $(element).data('youtube-id')); |
| 30 | + new AblePlayer($(this),$(element)); |
41 | 31 | } |
42 | 32 | }); |
43 | 33 | }); |
|
60 | 50 | // Construct an AblePlayer object |
61 | 51 | // Parameters are: |
62 | 52 | // media - jQuery selector or element identifying the media. |
63 | | - // startTime - the time at which to begin playing the media |
64 | | - window.AblePlayer = function(media, startTime, includeTranscript, transcriptDiv, youtubeId) { |
| 53 | + window.AblePlayer = function(media) { |
65 | 54 | // Keep track of the last player created for use with global events. |
66 | 55 | AblePlayer.lastCreated = this; |
67 | 56 |
|
|
73 | 62 | return; |
74 | 63 | } |
75 | 64 |
|
76 | | - if (transcriptDiv) { |
77 | | - this.transcriptDivLocation = transcriptDiv; |
| 65 | + // override defaults with values of data-* attributes |
| 66 | + |
| 67 | + var includeTranscript = media.data('include-transcript'); |
| 68 | + if (includeTranscript === undefined || includeTranscript === "") { |
| 69 | + // If there are caption tracks and no default provided, include transcript. |
| 70 | + if (media.find('track[kind="captions"], track[kind="subtitles"]').length > 0) { |
| 71 | + includeTranscript = true; |
| 72 | + } |
78 | 73 | } |
79 | | - |
80 | 74 | if (includeTranscript) { |
81 | 75 | this.includeTranscript = true; |
82 | 76 | } |
83 | 77 | else { |
84 | 78 | this.includeTranscript = false; |
85 | 79 | } |
86 | | - |
87 | | - if (startTime) { |
88 | | - this.startTime = startTime; |
| 80 | + |
| 81 | + if ($(media).data('start-time') !== undefined && $(media).data('start-time') !== "") { |
| 82 | + this.startTime = $(media).data('start-time'); |
89 | 83 | } |
90 | 84 | else { |
91 | 85 | this.startTime = 0; |
92 | 86 | } |
93 | 87 |
|
| 88 | + if ($(media).data('transcript-div') !== undefined && $(media).data('transcript-div') !== "") { |
| 89 | + this.transcriptDivLocation = $(media).data('transcript-div'); |
| 90 | + } |
| 91 | + |
| 92 | + if ($(media).data('youtube-id') !== undefined && $(media).data('youtube-id') !== "") { |
| 93 | + this.youtubeId = $(media).data('youtube-id'); |
| 94 | + } |
| 95 | + |
| 96 | + if ($(media).data('debug') !== undefined && $(media).data('debug') !== "false") { |
| 97 | + this.debug = true; |
| 98 | + } |
| 99 | + |
| 100 | + if ($(media).data('youtube-id') !== undefined && $(media).data('youtube-id') !== "") { |
| 101 | + // add validation |
| 102 | + this.youtubeId = $(media).data('youtube-id'); |
| 103 | + } |
| 104 | + |
| 105 | + if ($(media).data('volume') !== undefined && $(media).data('volume') !== "") { |
| 106 | + // add validation |
| 107 | + this.defaultVolume = $(media).data('volume'); |
| 108 | + } |
| 109 | + |
| 110 | + if ($(media).data('icon-type') !== undefined && $(media).data('icon-type') !== "") { |
| 111 | + // add validation |
| 112 | + this.iconType = $(media).data('icon-type'); |
| 113 | + } |
| 114 | + |
| 115 | + if ($(media).data('seek-interval') !== undefined && $(media).data('seek-interval') !== "") { |
| 116 | + // add validation |
| 117 | + this.seekInterval = $(media).data('seek-interval'); |
| 118 | + } |
| 119 | +console.log('seekInterval is ' + this.seekInterval); |
| 120 | + |
| 121 | + if ($(media).data('show-now-playing') !== undefined && $(media).data('show-now-playing') !== "false") { |
| 122 | + this.showNowPlaying = true; |
| 123 | + } |
| 124 | + |
| 125 | + if ($(media).data('fallback') !== undefined && $(media).data('fallback') !== "") { |
| 126 | + // add validation |
| 127 | + this.fallback = $(media).data('fallback'); |
| 128 | + } |
| 129 | + |
| 130 | + if ($(media).data('test-fallback') !== undefined && $(media).data('test-fallback') !== "false") { |
| 131 | + this.testFallback = true; |
| 132 | + } |
| 133 | + |
| 134 | + if ($(media).data('lang') !== undefined && $(media).data('lang') !== "") { |
| 135 | + this.lang = $(media).data('lang'); |
| 136 | + } |
| 137 | + |
| 138 | + if ($(media).data('lang-override') !== undefined && $(media).data('lang-override') !== "false") { |
| 139 | + this.langOverride = true; |
| 140 | + } |
| 141 | + |
94 | 142 | this.ableIndex = AblePlayer.nextIndex; |
95 | 143 | AblePlayer.nextIndex += 1; |
96 | 144 |
|
97 | | - this.youtubeId = youtubeId; |
98 | | - |
99 | 145 | this.title = $(media).attr('title'); |
100 | 146 |
|
101 | 147 | // populate translation object with localized versions of all labels and prompts |
|
190 | 236 | (function () { |
191 | 237 | // Set default variable values. |
192 | 238 | AblePlayer.prototype.setDefaults = function () { |
| 239 | + |
193 | 240 | // Debug - set to true to write messages to console; otherwise false |
194 | 241 | this.debug = false; |
195 | 242 |
|
|
256 | 303 | this.langOverride = true; |
257 | 304 |
|
258 | 305 | // translationDir - specify path to translation files |
259 | | - this.translationDir = '/translations/'; |
| 306 | + this.translationDir = '../translations/'; |
260 | 307 |
|
261 | 308 | this.setButtonImages(); |
262 | 309 | }; |
|
0 commit comments