b61f5b3a by Brandon Casey Committed by Jon-Carlos Rivera

remove no longer used audio button (#759)

1 parent 56cb8748
1 (function(videojs) {
2 var Component = videojs.getComponent('Component');
3
4 // -----------------
5 // AudioTrackMenuItem
6 // -----------------
7 //
8 var MenuItem = videojs.getComponent('MenuItem');
9
10 var AudioTrackMenuItem = videojs.extend(MenuItem, {
11 constructor: function(player, options) {
12 var track = options.track;
13 var tracks = player.audioTracks();
14
15 options.label = track.label || track.language || 'Unknown';
16 options.selected = track.enabled;
17
18 MenuItem.call(this, player, options);
19
20 this.track = track;
21
22 if (tracks) {
23 var changeHandler = videojs.bind(this, this.handleTracksChange);
24
25 tracks.addEventListener('change', changeHandler);
26 this.on('dispose', function() {
27 tracks.removeEventListener('change', changeHandler);
28 });
29 }
30 },
31
32 handleClick: function(event) {
33 var kind = this.track.kind;
34 var tracks = this.player_.audioTracks();
35
36 MenuItem.prototype.handleClick.call(this, event);
37
38 if (!tracks) return;
39
40 for (var i = 0; i < tracks.length; i++) {
41 var track = tracks[i];
42
43 if (track === this.track) {
44 track.enabled = true;
45 }
46 }
47 },
48
49 handleTracksChange: function(event) {
50 this.selected(this.track.enabled);
51 }
52 });
53
54 Component.registerComponent('AudioTrackMenuItem', AudioTrackMenuItem);
55
56 // -----------------
57 // AudioTrackButton
58 // -----------------
59 //
60 var MenuButton = videojs.getComponent('MenuButton');
61
62 var AudioTrackButton = videojs.extend(MenuButton, {
63 constructor: function(player, options) {
64 MenuButton.call(this, player, options);
65 this.el_.setAttribute('aria-label','Audio Menu');
66
67 var tracks = this.player_.audioTracks();
68
69 if (this.items.length <= 1) {
70 this.hide();
71 }
72
73 if (!tracks) {
74 return;
75 }
76
77 var updateHandler = videojs.bind(this, this.update);
78 tracks.addEventListener('removetrack', updateHandler);
79 tracks.addEventListener('addtrack', updateHandler);
80
81 this.player_.on('dispose', function() {
82 tracks.removeEventListener('removetrack', updateHandler);
83 tracks.removeEventListener('addtrack', updateHandler);
84 });
85 },
86
87 buildCSSClass() {
88 return 'vjs-subtitles-button ' + MenuButton.prototype.buildCSSClass.call(this);
89 },
90
91 createItems: function(items) {
92 items = items || [];
93
94 var tracks = this.player_.audioTracks();
95
96 if (!tracks) {
97 return items;
98 }
99
100 for (var i = 0; i < tracks.length; i++) {
101 var track = tracks[i];
102
103 items.push(new AudioTrackMenuItem(this.player_, {
104 'selectable': true,
105 'track': track
106 }));
107 }
108
109 return items;
110 }
111 });
112
113 Component.registerComponent('AudioTrackButton', AudioTrackButton);
114 })(window.videojs);
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
12 <!-- HLS plugin --> 12 <!-- HLS plugin -->
13 <script src="../../dist/videojs-contrib-hls.js"></script> 13 <script src="../../dist/videojs-contrib-hls.js"></script>
14 14
15 <!-- Track Selector plugin -->
16 <script src="audio-track-selector.js"></script>
17
18 <!-- player stats visualization --> 15 <!-- player stats visualization -->
19 <link href="stats.css" rel="stylesheet"> 16 <link href="stats.css" rel="stylesheet">
20 <script src="../switcher/js/vendor/d3.min.js"></script> 17 <script src="../switcher/js/vendor/d3.min.js"></script>
......