开发者

Is it possible to use the SeekBar component in YouTube ActionScript 3.0 Player API?

开发者 https://www.devze.com 2023-04-06 23:37 出处:网络
I\'m fiddling around with the YouTube ActionScript 3.0 Player API. It\'s pretty cool and simple but one thing i can\'t seem to get to work, nor find any info on the web:

I'm fiddling around with the YouTube ActionScript 3.0 Player API. It's pretty cool and simple but one thing i can't seem to get to work, nor find any info on the web:

I want to use the SeekBar component with the Youtube API. I tried开发者_运维问答 this, which works with the FLVPlayback component:

var seek:MovieClip = new SeekBar();
player.seekBar = seek;

So i think i might search wrong, try something impossible or thinking to easy? A push in the right direction will be appreciated.


It is possible and here is a tutorial explaining how to do it:

http://tutorialzine.com/2010/07/youtube-api-custom-player-jquery-css/

You can just implement your own seek bar, then when it's dragged or whatever get the value of the bar and apply it to the youtube object like so:

elements.player.seekTo();

See the tutorial for more information.


I created my own seekbar in the Flash IDE (can be a simple movieclip with 100x10px dimensions). It has a certain widht (variable) and can be clicked on. This is the function to skip to the movie position clicked.

    private function controlsSeek():void {

        // Get distance in pixels where the mouse is clicked
        var mouseGlobalPosition = new Point(mouseX,mouseY);
        var mouseLocalPosition = playerControls.seekbar.globalToLocal(mouseGlobalPosition);

        // Afstand van de balk vanaf het nulpunt
        var pixelsClicked:int =  mouseLocalPosition.x;
        // Percentage aan de hand van het aantal pixels
        var pixelsPercentage:int = (pixelsClicked / playerControls.seekbar.seekbarLoadedBackground.width) * 100;
        // Converteer pixels naar het aantal seconden waar de film heen moet
        var pixelsToSeconds:int = Math.ceil(pixelsPercentage * (player.getDuration() * 0.01));

        player.seekTo(pixelsToSeconds, true);

    }

It works for me, if someone has a better solution or idea please throw it at me. If you use this method and it works oké, please let me know also.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号