rewind button youtube api
A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: rewind button youtube api

  1. #1
    Junior Member
    Join Date
    Jan 2002
    Posts
    27

    rewind button youtube api

    Hello

    I'm trying to add a rewind button to my youtube api. I want the user to be able to jump back 10seconds with each click.

    i have the play and pause sorted:

    play_btn.addEventListener(MouseEvent.CLICK, playVid);
    function playVid(e:MouseEvent):void {
    my_player1.playVideo();
    }
    pause_btn.addEventListener(MouseEvent.CLICK, pauseVid);
    function pauseVid(e:MouseEvent):void {
    my_player1.pauseVideo();
    }

    Can anyone help me to take the current playhead position and move it -10seconds backwards?

    Many thanks!

    Dan

  2. #2

  3. #3
    Junior Member
    Join Date
    Jan 2002
    Posts
    27
    Thanks for that.
    I'm not sure how to use it.
    I"ve been taking my functions from here https://developers.google.com/youtub...yback_controls and playheadTime() isn't listed.

    i'm very unsure how to use as3....and using playheadTime() now throws up a new error:

    "Connection to https://www.youtube.com/api_video_info halted - not permitted from http://s.ytimg.com/yts/swfbin/player-vflZsDuOu/apiplayer3.swf"

    I've started with this, but i imagine i'm very wrong:

    rewind_btn.addEventListener(MouseEvent.CLICK, rewindVid);
    function rewindVid(e:MouseEvent):void {
    my_player1.playheadTime();
    }

    thank you again

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,059
    Hi,

    Maybe attach your *.fla and associated files for us to look at, it's hard sometimes without seeing the code and file.

  5. #5
    Junior Member
    Join Date
    Jan 2002
    Posts
    27
    I notice that there is a function:
    player.getCurrentTime():Number
    which returns the elapsed time in seconds since the video started playing.

    can I (somehow) combine the output from this with the seekTo() function
    something like ....!

    seekTo(getCurrentTime - 10)

    : / !!

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,059
    Hi,

    You can always test it, we can test it too if you attach your files if you have no luck

    https://developers.google.com/youtub..._api_reference
    Last edited by fruitbeard; 08-18-2014 at 08:09 AM.

  7. #7
    Junior Member
    Join Date
    Jan 2002
    Posts
    27
    Thanks for your time

    I've attached a test.fla with the minimum script. ...keep clicking the Load Video button until the video eventually loads! which it does, despite the mysterious error messages.

    I've stripped out the rest of the script of the current online working version, which can be viewed here....
    http://challengeyasuni.net/views_en.html


    kind regards
    Attached Files Attached Files

  8. #8
    Junior Member
    Join Date
    Jan 2002
    Posts
    27
    http://challengeyasuni.net/test/test.fla.zip

    try this zip file, the attachment didn't attach

  9. #9
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,059
    Hi,

    Well this works, so you were along the right lines, not sure if it's the best method though.
    PHP Code:
    function rewindVid(e:MouseEvent):void
    {
        var 
    currentTime:Number my_player1.getCurrentTime();
        
    trace(currentTime);
        
    my_player1.seekTo(currentTime 10) ;

    and if you wanted to make sure it has gone past 10 seconds before being able to rewind then simply add something like so
    PHP Code:
    function rewindVid(e:MouseEvent):void
    {
        var 
    currentTime:Number my_player1.getCurrentTime();
        
    trace(currentTime);
        if(
    currentTime 10)
        {
            
    my_player1.seekTo(currentTime 10);
        }

    the error is due to it being inside of flash, but you might need a crossdomain.xml file in your root, with code similar to this
    Code:
    <?xml version="1.0"?>
    <cross-domain-policy>
        <allow-access-from domain="*" />
    </cross-domain-policy>
    Swapping this

    Security.allowDomain("www.youtube.com");

    for this

    import flash.system.Security;
    Security.allowDomain("*");


    will stop you getting the errors inside of flash too
    Last edited by fruitbeard; 08-18-2014 at 08:39 AM.

  10. #10
    Junior Member
    Join Date
    Jan 2002
    Posts
    27
    wow!

    I am really grateful. That's a lot of know-how in your head.

    Thanks for sharing it with me and us all

    Very best

    Dan

  11. #11
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,059
    Hi

    one more thing, if you select File -> Publish Settings -> swf. local playback security and choose - Access network only

  12. #12
    Junior Member
    Join Date
    Jan 2002
    Posts
    27
    okay. that's good!! cheers again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com