Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can i control the player via javascript? #190

Open
inspurhua opened this issue May 28, 2015 · 9 comments
Open

can i control the player via javascript? #190

inspurhua opened this issue May 28, 2015 · 9 comments

Comments

@inspurhua
Copy link

i want to trigger play or pause in js, thank you

@Vlad-UA
Copy link

Vlad-UA commented May 28, 2015

Join to this question, thanks

@JMarqz
Copy link

JMarqz commented Jun 15, 2015

One more joining!
I'm looking for the same, I want take the control to play/pause the sounds via JS.

@eeeeeeeeeve
Copy link

You can call .playPause() on your audiojs instance.

@ikwyl6
Copy link

ikwyl6 commented Sep 12, 2015

How can you get the instance ? I've tried this, but it doesn't work:

audiojs.instances['0'].load($('a', this).attr('data-src'));

@Enverex
Copy link

Enverex commented Nov 19, 2015

Chiming in here too. Calling .play() on the audio element starts playing, but the actual element doesn't update and shows the pause icon still.

@ikwyl6
Copy link

ikwyl6 commented Nov 21, 2015

As far as I know - This is because you are accessing the html5 audio instance and not the audiojs instance.

@patricklewis
Copy link

As part of my work to write a script that would play sequentially through a list of multiple audio.js players on a page (representing CD tracks) I was able to call play() on audio.js instances and have the targeted player update to display a 'play' icon:

$('.audiojs').each(function(index) {
    var container = $(this);
    var audioPlayer = container.find('audio');

    audioPlayer.nextPlayerInstance = 'audiojs' + (index + 1);

    audioPlayer.on('ended', function() {
        if (audiojs.instances[audioPlayer.nextPlayerInstance]) {
            audiojs.instances[audioPlayer.nextPlayerInstance].play();
        }
    });
});

@hexplor
Copy link

hexplor commented Dec 16, 2016

@patricklewis you are my hero ! Thank you for this snippet :) You rock :) Thanks to that, i can control different playlists :)

@dekmekong
Copy link

Hello,

I had audiojs player on one of my ASP.NET page webform as show below and everything worked fine. My question is: Is there way to make the track play for only 30 seconds instead of the whole track after the play button was clicked? Thank you very much!

<audio preload ="auto">
            <source src ='TestSong.mp3' type ="audio/mp3" />
        </audio>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants