Vimeo Froogaloop API not recognizing an event


Solution 1

After hours and hours of frustration... I have found the solution.

Since I was using an ID on the iframe... apparently the vimeo API forces you to add the parameter to the URL you are fetching (player_id=iframe-id).

So the iFrame should look like this:

<iframe src="//" 
        width="623" height="350" frameborder="0"

Special thanks to Drew Baker for pointing this out:

Solution 2

Got an error creating the player element when selecting the iframe with jQuery.

var iframe = $('#player1');
var player = $f(iframe);

Results in

TypeError: d[f] is undefined

Solution for me was to select the first element in the jQuery ID selector

var iframe = $('#player1')[0];
var player = $f(iframe);

Solution 3

I think you're violating the Same Origin Policy. You'll notice here that where you're doing a lot of event handling, they are using special froogaloop API calls.

I've never used froogaloop so I'm probably wrong. But that's my guess. The errors seem to suggest that the iframe is attempting to modify the URL in your browser, and that's now allowed by Same Origin. That's why the API wraps up window.postMessage for you.

Solution 4

I had a similar issue, but in this case after replacing Froggaloop with the Vimeo.Player, it still it was a new restriction in chrome. I was getting the error "play() failed because the user didn't interact with the document first...". After further research it looks like Chrome added some restrictions see here. The solution in my case was to add allow="autoplay" to the iframe.


Related videos on Youtube

Author by


Updated on March 22, 2020


  • criticerz
    criticerz about 3 years

    I'm trying to recognize the onPlay, onPause, and onFinish event for vimeo using the froogaloop API. I've tried everything I could imagine with this thing, and no luck.

    I get this error on Firefox:

    Permission denied for <code><></code> to get pet property Location.toString

    And in Chrome:

    Unsafe javascript attempt to access frame with URL ... from frame with URL ` Domains, protocols and ports must match.

    Importing froogaloop from the CDN:

    <script src=""></script>

    My JS:

        var vimeoPlayer = document.querySelector('iframe');
        $f(vimeoPlayer).addEvent('ready', ready);
        function ready(player_id) {
            froogaloop = $f(player_id);
            function setupEventListeners() {
                function onPlay() {
                    function(data) {
                        console.log('play event');
                function onPause() {
                    function(data) {
                        console.log('pause event');
                function onFinish() {
                    function(data) {

    My HTML:

    <iframe src="" width="623" height="350" frameborder="0" id="iframe-video"></iframe>
  • criticerz
    criticerz almost 12 years
    What can I do to fix this then?
  • Doug Stephen
    Doug Stephen almost 12 years
    Adhere more to their pattern. For example, look at their SimpleButtons example; their evenListener callbacks are all calls to froogaloop API methods. Since you're adding an event listener to the froogaloop object that is trying to interact with your browser, you have to do it through their API. Also, looking at their API, I don't see an "addEvent" defined for a froogaloop object, just an addEventListener. They define their own addEvent in their example code that wraps addEventListener. Makes me think that there's a problem with using built-in addEvent related to Same Origin.
  • Drew Baker
    Drew Baker almost 12 years
    I made an example of how to use the Vimeo API here:…
  • RSG
    RSG over 11 years
    I'm still slogging through the 'hours of frustration' part. When I follow the examples given all I get are javascript security policy violations. How did you overcome these?
  • mheavers
    mheavers over 11 years
    doesn't seem to work for me - if I look at Drew Baker's example or implement the answer above I still get unsafe javascript errors - the player works, but the errors do not go away.
  • Elad Ziv
    Elad Ziv over 8 years
    This solution didn't work for me. I've found another fix for this: I'm playing the video and then pausing it as soon as the video is ready. This way, when the user tries to play it again, the video plays smoothly.
  • Melroy van den Berg
    Melroy van den Berg over 8 years
    I had some similar problem. My video is hidden by default. I tried to show the video first (via jQuery; ), and directly after this, I tried to call the: player.api('play'); . This results in really strange behavior, where the video doesn't play, or play after 30 seconds or so... At the end, I just created a separate function (let's say OnPlay), which only contains: player.api('play');. Now the line becomes :, OnPlay); This works! But Why?
  • Simon
    Simon over 8 years
    Useful link which clearly explains the OP 's question:…
  • malhar
    malhar about 7 years
    Did you get the answer @Max?
  • Maximilian Köhler
    Maximilian Köhler about 7 years
    Select the 1. JS object that is inside the jQuery selector with a [0] behind it, as statet at the bottom of my answer...
  • malhar
    malhar about 7 years
    I used it, however, I am getting the same error! iframe is undefined if I try to alert the same. Also, using Player_id ,and api=1,
  • Maximilian Köhler
    Maximilian Köhler about 7 years
    Can't help you, this worked for me... maybe post your code. greetings