2015-11-03 96 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"); 
     }); 
} 

我强烈建议你学习的例子,并了解每一行代码。如果您更改客户端中的值,但不要指示媒体服务器也更改该值,则该值无效。