使用 jquery 和 Kurento 更改图像源

changing the image source using jquery and Kurento

我用的是Kurento-magic-mirror,每次换图的时候,我都被迫改了图片的名字mario-Wings.png.

这是显示的代码

function getopts(args, opts)
{
  var result = opts.default || {};
  args.replace(
      new RegExp("([^?=&]+)(=([^&]*))?", "g"),
      function([=11=], , , ) { result[] = decodeURI(); });
 
  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){
  

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

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

如何解决这个问题???

请帮帮我...

您正在更改变量,但未对它执行任何操作。按照教程的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");
      });
}

我强烈建议您研究示例,并理解每一行代码。如果您在客户端更改了一个值,但不指示媒体服务器也更改该值,那是没有用的。