View Full Version : HTML5 support for non-FLV format video?
virtualuk
11-28-2010, 08:14 PM
Looking at the docs, it looks like with 4.9.0 (and I'm guessing before), the only video file format that is supported is FLV.
Is this correct?
Does anyone know of any impending HTML5 support for video in Openlaszlo coming soon? I'd love to embed video with my app, deploy it as DHTML and use it on the iPad/iPhone, but currently no dice.
bitwalker
11-29-2010, 06:52 PM
Well I do not know about the schedule for implementing audio video, but this is how I do it for audio. I think it will work for video too, but I have not tried:
You need to inject the html5 tags into the innerHtml of a text box, and then call it from java script code. I wrote a class called audionode that handles this.
There is a DHTML and a FLASH implementation which are compiled conditionally.
<switch>
<when property="$dhtml">
<!-- An html5 audionode -->
<class name="audionode" extends="text">
<attribute name="autoplay" value="false" />
<attribute name="loopplay" value="false" />
<attribute name="audiosrc" type="text" />
<attribute name="divid" type="text" value="$once{'lzaudio_' + this.name + '_' + Math.random(10000000)}" />
<handler name="oninit">
this.resetNode();
Debug.write("this.name:" ,this.name )
</handler>
<handler name="onaudiosrc">
this.resetNode();
</handler>
<handler name="ondata">
this.resetNode();
</handler>
<method name="resetNode">
<![CDATA[
if (!this.audiosrc) return;
var autoplayString = '';
var loopplayString = '';
if (this.autoplay) {autoplayString=" autoplay='true'"};
if (this.loopplay) {loopplayString=" loop='true'"};
this.setAttribute("text","<audio id='" + this.divid + "' src='" + this.audiosrc + "'" + autoplayString + loopplayString + " />");
if (this.autoplay) {this.play()};
]]>
</method>
<method name="load" args="ignore=null">
<![CDATA[
if (this.audiosrc != null && this.audiosrc !=""){
lz.Browser.loadJS("document.getElementById('" + this.divid + "').load()");
}
]]>
</method>
<method name="play" args="ignore=null">
<![CDATA[
if (this.audiosrc != null && this.audiosrc !=""){
this.load();
lz.Browser.loadJS("document.getElementById('" + this.divid + "').play()");
}
]]>
</method>
<method name="stop" args="ignore=null">
<![CDATA[
if (this.audiosrc != null && this.audiosrc !=""){
lz.Browser.loadJS("document.getElementById('" + this.divid + "').stop()");
}
]]>
</method>
</class>
</when>
<otherwise>
<!-- If it is flash set up a resource based sound node -->
<class name="audionode" extends="view">
<attribute name="audiosrc" type="text" />
<attribute name="autoplay" value="false" />
<attribute name="loopplay" value="false" />
<handler name="onaudiosrc">
this.initaudio();
</handler>
<handler name="oninit">
this.initaudio();
</handler>
<handler name="ondata">
this.initaudio();
</handler>
<method name="initaudio">
<![CDATA[
if (!this.audiosrc) return;
this.setSource("http:" + this.audiosrc);
this.setAttribute("loop",this.loopplay);
if(!this.autoplay){
this.stop();
}
Debug.write("initing sound with:", this.audiosrc);
]]>
</method>
<handler name="onlastframe">
if (this.loopplay){
this.play(1);
}
</handler>
</class>
</otherwise>
</switch>
And use it like this:
<audionode name="backgroundaudio" audiosrc="resources/backloop.mp3" autoplay="true" loopplay="true" />
Or like this:
<audionode name="someaudio" audiosrc="resources/asound.mp3" autoplay="false" loopplay="false" />
<handler name="onclick">
this.someaudio.play();
</handler>
You could modify the code for video pretty easily I think. Check out the Apple documentation for HTML5 and safari. Be careful though on iOS there are a few things that don't work as expected.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.