C2 Video Plugin to support "controls" and "track"

Discussion and feedback on Construct 2

Post » Tue Mar 03, 2015 7:11 pm

There are 3 small enhancements I'd like to suggest for the Video HTML5 exporter plugin.

The first one allows to programmatically add the Controls with options: No|When Requires Touch|Always
The second attaches a VTT file for Close Captioning
The third one allows you to define a thumbnail, by setting the 'poster" attribute of the HTML5 Video element to a picture

Changes are very easy. Please consider adding these 2 features in a future release of Construct2

Hugo

1- design time JS, add the following properties
new cr.Property(ept_text, "Track File (*.vtt) ", "", "Standard VTT track file for the video. See "),
new cr.Property(ept_combo, "Controls", "No", "Add controls to the video.", "No|When Requires Touch|Always"),
new cr.Property(ept_text, "Poster File (*.png | *.gif) ", "", "Poster file used as thumbnail "),

2- runtime.js in instanceproto.onCreate= function(){ (Add around line 220)

if (this.video.hasAttribute("controls") && this.properties[7]==0){
this.video.removeAttribute("controls");
}
if (!this.video.hasAttribute("controls") && this.properties[7]==2){
this.video.setAttribute("controls", "true");
}
if (!this.video.hasAttribute("controls") && this.properties[7]==1 && this.useNextTouchWorkaround){
this.video.setAttribute("controls", "true");
}
if (this.properties[6]){

var track = document.createElement("track");
track.src = this.properties[6];
track.kind="subtitles";
track.label="English subtitles"
track.srclang="en"
//track.default="default";
this.video.appendChild(track);
}
if (this.properties[8]){

if (this.video.hasAttribute("poster") ){
this.video.removeAttribute("poster");
}
this.video.setAttribute("poster", properties[8]);

}
B
5
S
1
Posts: 10
Reputation: 419

Return to Construct 2 General

Who is online

Users browsing this forum: Arcosta and 12 guests