After all the work, I was able to reduce the player to about 30 lines of
code (see below). This works at least as well as the more complex version
with switching preloaded videoviews on and off.

Herr is how it works:

#ma Starts playing the video. It also calls preload() which fetches the
next chunk in #mb.

If #ma signals 'stop', the url will be set to the previously pre-fetched
url and #ma will now play the new url and the loop continues.

That also illustrate my problem: It simply takes a 100ms or so to set the
new URL up.

Is there any way how I would be able to speed up the process of switching
video sources?

Thanks.

Michaela

-------------------------- Source -------------------------------------

<canvas debug="true">
<view width="400" height="300" />
<mediastream name="ma" type="http"
url="http://www.sigme.us/video/video-10.mp4"; autoplay="false">
<handler name="oninit">
       canvas.ma.play();
       preload();
</handler>
<handler name="onstop">
      switchVideo();
</handler>
</mediastream>
<videoview name="va" id="iva" visible="1"  type="http" autoplay="true"
width="512" height="288" stream="canvas.ma" />

<mediastream name="mp" muteaudio="1" type="http"
url="http://www.sigme.us/video/video-2.mp4"; autoplay="false" />
<videoview name="vb" playvolume="0" id="ivb" visible="0"  type="http"
autoplay="true" width="512" height="288" stream="canvas.mp" />

<text y="295" name="cur"  text="${canvas.ma.time}"/>
<script>

 <![CDATA[
var counter = 11;
var what=0;
function
preload()       {
        var url = "http://www.sigme.us/video/video-"+counter+".mp4";;
        canvas['vb'].setAttribute("playvolume","0");
        canvas.mp.close();
        canvas.mp.setAttribute("url",url);

        canvas.mp.setAttribute("url",url);
        canvas['vb'].setAttribute("playvolume","0");
        canvas.mp.play();
        }

function
switchVideo()   {
        var url = "http://www.sigme.us/video/video-"+counter+".mp4";;
        canvas.ma.setAttribute("url",url);
        canvas.ma.play();
        counter++;
        var f = function()      {
                preload();
                }
        setTimeout(f,1500);
}
]]>
</script>
</canvas>


Reply via email to