Flex 4 spark VideoDisplay - Keep videoDisplay time on different video source

303 views
Skip to first unread message

Arulmurugan

unread,
Sep 19, 2011, 1:05:36 AM9/19/11
to chennai-fle...@googlegroups.com

Hi I am having a spark videoDisplay control and I have two bttons on clicking button 1 I am changing the source of the VideoDisplay to video1.flv and on clicking button 2 I am chinging the source to video2.flv.

What I need is on changing the video source I have to maintain the time played on video1 to be set on video2.

I Tried like videoDisplay.seek(cTime) where currentTime variable holds the org.osmf.events.TimeEvent Time property which I assing in the currentTimeChange handler of the videoDisplay.

Included the code below.

public var cTime:Number = 0;

public function videoPlayer_playheadUpdate(evt:org.osmf.events.TimeEvent):void

{           

       cTime = evt.time;

}

public function playVideo(value:String):void

{

        videoDisplay.source = value ;

        videoDisplay.seek(cTime);

}

<s:VideoDisplay id="videoDisplay" currentTimeChange="videoPlayer_playheadUpdate(event)" />

<s:Button click='playVideo("assets/videos/backview.flv")' label="Back"></s:Button>

<s:Button x="309" y="1" label="Front" click='playVideo("assets/videos/frontview.flv")'></s:Button>

Arun Venkataswamy

unread,
Sep 19, 2011, 3:08:51 AM9/19/11
to chennai-fle...@googlegroups.com
On Mon, Sep 19, 2011 at 10:35 AM, Arulmurugan <arulmu...@gmail.com> wrote:

<s:Button click='playVideo("assets/videos/backview.flv")' label="Back"></s:Button>


 Do something like
<s:Button click='currentime=c;playVideo("assets/videos/backview.flv");seekto(c)' label="Back"></s:Button>

You have not mentioned whether your code is working or not! I am assuming it is not working...
Your code is probably not working because the moment you are changing the source, the playback probably began from the beginning and also called the time change event which will record the new time in c very close to the start of the new video. It is better to get the current time and then manually set it after changing the source.

Regards,
Arun


Arun Venkataswamy

unread,
Sep 19, 2011, 3:10:03 AM9/19/11
to chennai-fle...@googlegroups.com
On Mon, Sep 19, 2011 at 12:38 PM, Arun Venkataswamy <aru...@gmail.com> wrote:
On Mon, Sep 19, 2011 at 10:35 AM, Arulmurugan <arulmu...@gmail.com> wrote:

<s:Button click='playVideo("assets/videos/backview.flv")' label="Back"></s:Button>


 Do something like
<s:Button click='currentime=c;playVideo("assets/videos/backview.flv");seekto(c)' label="Back"></s:Button>


The code above is psedo code. Just algorithmic. Use the correct seek to method :)

Regards,
Arun
 

Arulmurugan

unread,
Sep 20, 2011, 2:49:47 AM9/20/11
to chennai-fle...@googlegroups.com
Hi Venkat, 

Thanks for your reply.

I tried that also. But the video simply doesnt playing.

see my updated code below.
[Bindable]
public var cTime:Number = 0;

public function playVideo(value:String):void
{
cTime = videoDisplay.currentTime;
videoDisplay.source = value ;
                        videoDisplay.seek(cTime);
                }

In the docs they have specified that if the videoDisplay.mediaPlayerState is in loading or ready state the seek wont work fine.

When I gave an alert and checked it is in ready state or buffering state. In either state the seek doesnt works.
Reply all
Reply to author
Forward
0 new messages