2015-11-03 67 views
0

我使用Kurento魔鏡和每次我會改變圖像,我被迫改變圖片的名稱mario-Wings.png。使用jQuery和Kurento更改圖像源

這裏是代碼所示

function getopts(args, opts) 
 
{ 
 
    var result = opts.default || {}; 
 
    args.replace(
 
     new RegExp("([^?=&]+)(=([^&]*))?", "g"), 
 
     function($0, $1, $2, $3) { result[$1] = decodeURI($3); }); 
 
    
 
    return result; 
 
}; 
 
    
 
var args = getopts(location.search, 
 
{ 
 
    default: 
 
    { 
 
    ws_uri: 'ws://' + location.hostname + ':8888/kurento', 
 
    hat_uri: 'http://' + location.host + '/img/mario-wings.png', 
 
    ice_servers: undefined 
 
    } 
 
});

假設我們在界面 有幾個圖片現在,我想通過製造點擊改變形象。

我開始創建一個功能,但該功能通過對這種改變在啓動

function changeImage(nom){ 
 
\t \t 
 

 
\t console.log(" Avant Changement de l'image "); 
 
\t args = getopts(location.search, 
 
\t { 
 
\t default:{ 
 
\t \t  ws_uri: 'ws://' + location.hostname + ':8888/kurento', 
 
    \t    hat_uri: 'http://' + location.host + '/img/test5.jpg', 
 
\t \t  ice_servers: undefined 
 
\t \t } \t 
 
     }); 
 

 
\t $("#test5").attr('src', 'img/test5.jpg'); 
 
\t console.log("Après Changement de l'image "); 
 
\t \t \t 
 
}

如何解決這個問題的圖片是不是自動的???

請幫助我......

回答

0

你正在改變的變量,但沒有做任何事的。繼本教程的lead,這是你需要做什麼

function changeImage(hatUri, offsetXPercent, offsetYPercent, widthPercent, heightPercent) { 
    filter.setOverlayedImage(hatUri, offsetXPercent, offsetYPercent, widthPercent, heightPercent, 
     function(error) { 
     if (error) return onError(error); 
     console.log("Set overlay image"); 
     }); 
} 

我強烈建議你學習的例子,並瞭解每一行代碼。如果您更改客戶端中的值,但不要指示媒體服務器也更改該值,則該值無效。