Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

FLV Player button to seek to next cue point (or previous)?

Contributor ,
Dec 01, 2015 Dec 01, 2015

Hello all,

I have a FLV player on my stage linked to a .flv with embedded cue points. (added and exported in an older version of Media Encoder)

I have added the following code, which pauses the player at each of the embedded cue points

import fl.video.MetadataEvent;

player.addEventListener(MetadataEvent.CUE_POINT, fl_CuePointHandler_3);

function fl_CuePointHandler_3(event:MetadataEvent):void

{  player.pause();

}

I would dearly love the back and next buttons on the Skin to have the ability to skip to the next or previous Cue points but they seem to just skip to small increments of time instead.

I can live with custom buttons on the stage that will give the user ability to seek to the next or previous Cue points. Can any one help me with what code would go on these buttons please.

Thanks in advance. 🙂

TOPICS
ActionScript
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2015 Dec 01, 2015

you can only seek to parts of the flv that's been downloaded.  other than that, there should be no problems if your seek() is correct.

what code are you using that's failing, especially when seeking to previously played (and therefore downloaded) cue points?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 01, 2015 Dec 01, 2015

Hi Kglad, Thanks for your response.

What code should I put on a button that would skip to the previous embedded Cue Point?

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2015 Dec 01, 2015

function prevCuePointF(e:MouseEvent):void{  // assuming mouseevent calls

player.findNearestCuePoint(player.totalTime,'all');

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 01, 2015 Dec 01, 2015

Hmmm, I can't seem to get this to work. Please forgive my ignorance. Am I missing something very obvious here?

My Cue Points are set to Navigation. Should they be Event?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2015 Dec 01, 2015

that code works for all cuepoint types.  if you wanted to limit it to seeking for a previous cuepoint of a particular type, you would use that type-string instead of 'all'.

but i have an error.  use:

function prevCuePointF(e:MouseEvent):void{

player.findNearestCuePoint(player.playheadTime,'all');

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 01, 2015 Dec 01, 2015

I still can't get that to work

I've tried creating a button and pasting your new code on the button, but when clicked the button does nothing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2015 Dec 01, 2015

use the trace function to debug:

import fl.video.MetadataEvent

player.addEventListener(fl.video.MetadataEvent.METADATA_RECEIVED,f);

function f(e:fl.video.MetadataEvent):void{

    for(var s:String in e.info){

        if(e.info is Object){

            for(var ss:String in e.info){

                trace(ss,e.info[ss]);

            }

        } else {

            trace(s,e.info);

        }

    }

}

function prevCuePointF(e:MouseEvent):void{

trace(player.playheadTime);

player.findNearestCuePoint(player.playheadTime,'all');

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 01, 2015 Dec 01, 2015

I'm sorry, I do appreciate your help with this, but I have no idea where to put this code and how does this make a button click take you to the previous Cue Point?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2015 Dec 01, 2015

you have to create that button.  you can do that with code or in the ide.

then add a listener to that button to call prevCuePointF:

import fl.video.MetadataEvent

yourbutton.addEventListener(MouseEvent.CLICK,prevCuePointF);

player.addEventListener(fl.video.MetadataEvent.METADATA_RECEIVED,f);

function f(e:fl.video.MetadataEvent):void{

    for(var s:String in e.info){

        if(e.info is Object){

            for(var ss:String in e.info){

                trace(ss,e.info[ss]);

            }

        } else {

            trace(s,e.info);

        }

    }

}

function prevCuePointF(e:MouseEvent):void{

trace(player.playheadTime);

player.findNearestCuePoint(player.playheadTime,'all');

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015

Hi Kglad, Button created and new code placed onto it.

When tested the time of the current location of the playhead is shown in the output panel. Which is nice.

How do we now use this information to make the button click take us to the previous cue point?

Thanks again for your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2015 Dec 02, 2015

are cue points listed from the metadata listener function?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015

When you first export, it lists 0 to 9 in the output panel? This corresponds to the same number of Cue points. Is that what you mean?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2015 Dec 02, 2015

upload your flv to a file server and post a link to it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2015 Dec 02, 2015

it looks like cue points aren't assigned properly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015

The cue points are added using media encoder.  If they aren't assigned properly then I wonder why / how they are recognised by flash?

cuepoints.jpg

Plus the code I used to pause the play head as it reaches each cue point works. leading me to believe there are Cue Points embedded in this FLV.

//*code to pause playhead at each cue point

import fl.video.MetadataEvent;

player.addEventListener(MetadataEvent.CUE_POINT, fl_CuePointHandler_3);

function fl_CuePointHandler_3(event:MetadataEvent):void

{  player.pause();

}

So I'm wondering what it is that I'm missing here?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015

Here a screen shot of Media encoder as you place in the Cue Points.

I wonder if it's something to do with the Parameter names? None of the tuts I've looked at mention anything about these though.

Parameter_Names.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2015 Dec 02, 2015

you're right.

use:

function prevCuePointF(e:MouseEvent):void{

player.seek(player.findNearestCuePoint(player.playheadTime,'all').time)

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015

Hmm. I added it here: But it still doesn't work.

Should I be adding something to the Parameter names as I export the FLV?

Screen Shot 2015-12-02 at 17.27.50.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2015 Dec 02, 2015

you need to change prevCuePointF

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015

I do? Which one and what to and also why?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2015 Dec 02, 2015

again, use:

function prevCuePointF(e:MouseEvent):void{

player.seek(player.findNearestCuePoint(player.playheadTime,'all').time)

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 02, 2015 Dec 02, 2015

Thanks for your patience Kglad . It is sort of working now, although unfortunately the button will only work whilst the playhead is running, not while it's paused. Also it jumps to the closest Cue point rather than the previous one.

Part of the functionality that I need is for the playhead to pause at each cue point. Then if the user so desires a button can be clicked to go to the previous cue point.

Once again, thanks for your help with this, however in the interest of making something usable and since I'm not able to understand the AS3 I'm going to re-think the nav and come up with another plan. I can't keep looting snippets of knowledge from your brain and hoping they will work, without understanding whats going on.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2015 Dec 02, 2015
LATEST

you're welcome.

if you get desperate you can hire me to finish this for you.  or you can keep getting snippets of code to help with limited problems free via the adobe forums.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines