2012-01-21 165 views
1

我有這個非常簡單的代碼。我遇到了一些問題。vimeo和javascript(froogaloop) - 獲取視頻信息

<!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> 

首先,PLAY,PAUSE,MUTE和音量滑塊(僅限webkit)等按鈕可以正常工作。 但是,當我需要從視頻中獲取一些視頻數據,並打印的地方(控制檯,例如)沒有什麼作品,並表示這樣的消息:

ERROR in Chrome

搜索在這裏我找到了一些有關的問題但是,對他們來說,這種運作根本不適合我。哎呀!

任何人都可以幫助我嗎?謝謝。

回答

0

你有這個錯誤,因爲你正在播放你的視頻作爲本地文件。您必須在Web服務器上運行您的代碼(甚至可以在本地使用MAMP或WAMP)。

Ken。