How to determine if colab ipd.audio player has stopped playing - javascript

I am trying to figure out how to tell if an ipd.Audio player on colab has finished playing so that code can execute afterwards. Is there some way to handle it through a javascript event? Thanks.

To do this, use the HTML Audio event directly and register an event handler on the ended event.
Here's the full example notebook:
https://colab.research.google.com/drive/15FbPqHyY1sgqtLBTJFK8ROgeUMa2syzf?usp=sharing

Related

How to trigger CuteUpload's UploadStart event using Jjavascript?

I want to trigger a Javascript function after CuteUpload's upload event start, but I don't understand how to call the event.
Any help would be nice.
Here is the user manual, with some confusing explanation about Javascript events can be found at bottom of the page.

How do you get the state of a youtube video on youtube.com?

I'm trying to make a chrome extension that needs the state of the youtube video player, and I'm aware of the existence of the API but my attempts to actually use it have been fruitless. Can someone point me in the right direction?
You'll want to subscribe to the onStateChange event as described here: https://developers.google.com/youtube/js_api_reference?csw=1#SubscribingEvents
The states of the player are described in the documentation for the onStateChange event on the same page.
What I was looking for is that you have to call the API methods on this div and that wasn't made clear in the docs.
document.getElementById('movie_player');
Moreover if anyone else ends up here go ahead an read this:
Insert code into the page context using a content script

Wordpress: how to get events from the default audio player?

I'm currently using Wordpress 4.0 and all my audios on posts/pages are embedded using the default Wordpress audio player - through a shortcode like:
[audio http://en.support.files.wordpress.com/2012/05/mattmullenweg-interview.m4a]
Now, I want to track how many times the play button is pressed. So, my question is: how can I capture this player events?
PS: I tried the following (and it didn't work):
$('.mejs-playpause-button button').click(function(){
console.log('TESTING');
});
It's possible that the event propogation for that button is being prevented by the MediaElementJS library that manages the audio element.
As an alternative I would suggest listening for 'play' events on either the MediaElementJS element or directly selecting the native HTML audio element and listening for the 'play' event on this object.
I briefly attempted to get the MediaElementJS instance for a player but it is hard to get hold off because of the way that Wordpress makes these instances.
However you can add an event listener to an audio element and record the amount of times this element is fired:
$('audio').on('play', function(){
console.log("play");
});
This might not be the best solution if you have multiple elements on a page though.

Google Analytics Event tracking with FullPage.js

I am trying to figure out the best way to attach unique
onclick="_gaq.push(['_trackEvent','content block','click','section1 arrow']);"
event tracking code on each arrow as well as the slide bullets. I've seen code that can be loaded AfterLoad, but i need the event tracking. Has anyone done this before or know how it could be properly implemented?

How to detect an audio has finished playing in a web page?

In my project, I need to embed audio (ex: mp3, etc) into a web page. When user visits the page, the audio will begin playing. When the audio ends, the questionnaire (form fields) will appear for the user to answer.
Is there is way to check if the audio has finished playing using jquery, so that the questionnaire can appear after the user has listened to the entire audio?
I know one way to check is to determine the audio length, then I can set a timer to display the questionnaire, but I'm hoping jquery has some sort of event handler that allows me to accomplish this.
I see that jquery has many audio plugins, and I can't be sure which will do what I want here: http://plugins.jquery.com/plugin-tags/audio
Any ideas are greatly appreciated.
Thanks.
If you are using the html5 audio tag, there is the "onended" event handler. I donĀ“t know if the browsers support it yet.
Something like:
<audio src="xpto.mp3" onended="DoSomething();"></audio>
In the last case you can use a swf that can play the sound, and alert your javascript when it reaches the end.
You can also add a jQuery event listener like so:
$("audio").on("ended", function() {
console.log("All Done!");
});
Using JavaScript event listener.
var myAudio = document.getElementById("myAudioId");
myAudio.addEventListener("ended", function() {
alert("The audio has ended.");
};

Categories

Resources