Exploring Vimeo APIs with JavaScript (Froogaloop) for Retrieving Video Details

I'm encountering issues with a relatively simple code that I have.

<!DOCTYPE html>
<html>
  <head>    
  <!--
  <script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>
  -->
  <script src="https://raw.github.com/vimeo/player-api/master/javascript/froogaloop.js"></script>
  </head>

  <body>

    <iframe
        id="vimeo_1"
        src="http://player.vimeo.com/video/7100569?api=1&player_id=test"
        width="400"
        height="225"
        frameborder="0">
    </iframe>

    <a id="play" href="javascript:void(0)">play</a>
    <a id="pause" href="javascript:void(0)">pause</a>
    <a id="mute" href="javascript:void(0)">mute</a>
    <input id="volume" type="range" min="0" max="1" value="0.5" step="0.01" />
    <a id="videoInfo" href="javascript:void(0)">video info</a>

    <div>
        <ul id="showVideoInfo">
        </ul>
    </div>

    <div id="debug"></div>

    <script>
    var v1 = document.getElementById('vimeo_1');
    var play = document.getElementById('play');
    var pause = document.getElementById('pause');
    var mute = document.getElementById('mute');
    var volume = document.getElementById('volume');
    var videoInfo = document.getElementById('videoInfo');

    var debug = document.getElementById('debug');

    $f(v1).addEvent('ready', function(pID){
        console.log('ready');
    });

    addEvent(play, 'click', playVideo);
    addEvent(pause, 'click', pauseVideo);
    addEvent(mute, 'click', muteVideo);
    addEvent(volume, 'change', volumeVideo);
    addEvent(videoInfo, 'click', infoVideo);

    function addEvent(obj, name, callback) {
        if (obj.addEventListener)
            obj.addEventListener(name, callback, false);
        else
            obj.attachEvent(name, callback, false);
    }

    function playVideo() {
        console.log('play');
        $f(v1).api('play');
    }

    function pauseVideo() {
        console.log('pause');
        $f(v1).api('pause');
    }

    function muteVideo() {
        console.log('mute');
        $f(v1).api('setVolume', 0);
    }

    function volumeVideo() {
        console.log(this.value);
        $f(v1).api('setVolume', this.value);
    }

    function infoVideo() {
        console.log('videoInfo: ');
        $f(v1).api('paused', function(v) {
            console.log(v);
        });
    }
    </script>

  </body>

</html>

Initially, functionalities like PLAY, PAUSE, MUTE, and the volume slider (webkit only) are functioning properly. However, when attempting to retrieve video data and display it somewhere (e.g., console), nothing seems to be working - an error message is displayed:

After looking through some related questions, I haven't had much luck with the solutions provided by others. Can anyone offer assistance? Thank you.

Answer №1

The reason for the error is due to playing the video as a local file. To resolve this, you need to execute your code on a web server (even if it's running locally with MAMP or WAMP).

Sincerely, Ken

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Dealing with Lengthy Requests: Effective Strategies

My ajax request sometimes takes a while to return a response. $.ajax({ type: 'POST', url: 'some_url', data: data, processData: false, contentType: false, headers: { "Authorization": 'Token token="&a ...

Cypress - Mastering negative lookaheads in Regular Expressions

While experimenting with Cypress, I encountered an issue regarding a filter test. The goal is to verify that once the filter is removed, the search results should display values that were filtered out earlier. My attempt to achieve this scenario involves ...

How can JavaScript/jQuery be used to update LocalStorage Objects when editing a form?

Having trouble pinpointing an issue with my code. Despite making modifications, the values in localStorage are not updating as expected. Any suggestions on what may be causing this problem? Note: Changing const idx to const i resulted in only the final va ...

What is the best way to show a message within a specific HTML division with JavaScript?

Here's my attempt at solving the issue: <head> <script> function validateForm() { var username = document.forms["login"]["uname"].value; var password = document.forms["login"]["pwd"].value; if (username == "" || p ...

Using JSDoc and Visual Studio Code: Writing documentation for a function that is being passed as an argument to another

Struggling to properly document the input parameters for a JavaScript function using JSDoc. The documentation suggests using the @callback comment, but Visual Studio Code (VSCode) doesn't seem to recognize it. In VSCode, the intellisense for the loca ...

Pressing the button will allow you to select and copy the text within the

I am looking to incorporate a mock-chat feature into my website. The concept is to type something on the website, then click a button next to it which will move the text to a frame above. I attempted this using a textarea and even found a code for selectin ...

Looking to retrieve the raw HTTP header string in Node.js using express.js?

Currently, I am utilizing Node.js and express.js for my work. The project I am currently working on requires me to access the raw strings of the HTTP headers (charset and accepted). In express.js, there is a function available that can provide the charset ...

Tips for resolving the error message "Uncaught TypeError: Cannot read property '0' of undefined" in React rendering

When I try to map through my list in the render function, it doesn't work, even though it works fine within my component class DesktopList extends Component { constructor(props) { super(props); this.state = { i ...

Retrieving a single post from a JSON file using AngularJS

I'm currently delving into AngularJS, but I seem to be stuck on what might be a simple issue. At the moment, I have some hardcoded JSON files with a few persons in them and no actual backend set up yet. In my form, I aim to display a single person ea ...

Experiment with parsing multiple outputs instead of repeatedly coding them as constants in Node.js

In my application, I am parsing multiple database data using cron and currently, I have it set up to create a const run for each data to find the dag_id and manually test the determineCron function one at a time. How can I create an array so that the "dete ...

React - Obtain User Login Details and Verify

I am working on a React project that includes a Login Form. The code has been organized into small components for reusability, but I am unsure of how to retrieve and validate user credentials (username and password). Is there a method available to validate ...

Using AJAX (jQuery) to process and refine JSON data through filtration

I need assistance with filtering a JSON array using AJAX but I'm unsure of how to proceed. { posts: [{ "image": "images/bbtv.jpg", "group": "a" }, { "image": "images/grow.jpg", "group": "b" }, { "image": "images/tabs.jpg", ...

Hybrid component that combines static and dynamic elements in Gatsby

The inconsistency in behavior between the site generated by gatsby develop and gatsby build is causing an issue where the site works during development but not when it's in production. An overview of my website: My website is a simple blog-like plat ...

What is the best way to implement onChange for multiple form fields in Reactjs?

Can anyone help me troubleshoot my form? I'm having issues with typing into the fields and nothing happens when I try. Initially, whatever text I input would show up in all the fields simultaneously, but after making some changes, it stopped working ...

How can I pass a value into a form within a modal in Bootstrap?

I am currently in the process of developing a university search website. When users enter a keyword, it will return results and display them in cards. Each card will have an 'Add review' button. Upon clicking this button, a modal will pop up cont ...

Use JavaScript to create a new window and load the HTML content from an external URL

Just starting out with HTML and Javascript I'm trying to use JavaScript to open a window and load content from an external source. I attempted using document.write(), but it only works when I hardcode the HTML as input. Any suggestions on how to get ...

What is the best way to integrate Express JS with Google Charts?

I'm currently working on an Express application and I need to integrate Google charts into it. I found this helpful article here for guidance. Additionally, I would like to know how to replace manual data with data from a MySQL database. ...

AngularJS is failing to update the shared service model

Utilizing AngularJS, my application contains two controllers that share a common service. When triggering an event controlled by the portalController function (specifically the setLang() function), I notice that the model of the applicationController does ...

Determine if a class is odd or even in Angular by utilizing ng-click

Trying to alternate classes on elements in an ng-repeat loop based on whether they are even or odd... <div ng-click="displayHTML(content)" ng-class-odd="'title'" ng-class-even="'html'" ng-repeat="content in name.name"> {{cont ...

Jsx Component fails to display following conditional evaluations

One issue I am facing is having two separate redux stores: items (Items Store) quotationItems (Quote Items). Whenever a product item is added to quotationItems, I want to display <RedButton title="Remove" />. If the quotationItems store i ...