事实上,您可以在 Videogular 中使用 html5 轨道,这很容易做到。
在您的控制器中:
this.tracks = [
{
src: "assets/subs/pale-blue-dot.vtt",
kind: "captions",
srclang: "en",
label: "English",
default: "default"
},
{
src: "assets/subs/pale-blue-dot-es.vtt",
kind: "captions",
srclang: "es",
label: "Spanish",
default: null
}
]
this.changeTrack = function () {
this.media[0].tracks[0].default = null;
this.media[0].tracks[1].default = "default";
};
在您的模板中:
<videogular>
<vg-media vg-src="ctrl.sources"
vg-tracks="ctrl.tracks"
vg-native-controls="true">
</vg-media>
<vg-controls>
<vg-play-pause-button></vg-play-pause-button>
<vg-time-display>{{ currentTime | date:'mm:ss' }}</vg-time-display>
<vg-scrub-bar>
<vg-scrub-bar-buffer></vg-scrub-bar-buffer>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
</vg-scrub-bar>
<vg-time-display>{{ timeLeft | date:'mm:ss' }}</vg-time-display>
<vg-playback-button></vg-playback-button>
<vg-volume>
<vg-mute-button></vg-mute-button>
<vg-volume-bar></vg-volume-bar>
</vg-volume>
<vg-fullscreen-button></vg-fullscreen-button>
<button ng-click="ctrl.changeTrack()">Change track</button>
</vg-controls>
</videogular>
演示: http: //videogular.com/demo/#/
代码:https ://github.com/2fdevs/videogular/tree/master/app