AGORA :I want to remove localstream when call ends - agora.io

I want to remove localstream when call ends. I am using
var localStream = AgoraRTC.createStream({audio: true, video: true});
localStream.removeTrack(localStream.getAudioTrack());
but giving me error
localstream.getAudioTrack is not a function
Please help actually I want to remove localstream when call ends
I am writing that code in
this.client.on('peer-leave', function (evt)

function localStream.getAudioTrack() is not supported in AGORASDK2.4.0.js(version)
if you want to use this function must use the version 2.5 and Greater version.
and then use the functions from Agora Documentation according to the version which you are using.

Related

dragAndDrop using webdriverio

I have tried every single thing to perform dragAndDrop using webdriverio but nothing works. I have also posted a question in the webdriverio gitter but no response. below posted code is one of the ways I tried and its supposed to work but it just doesn't!
` await this.driver.moveToObject(source);
await sleep(2000);
await this.driver.buttonDown(0);
await sleep(2000);
await this.driver.moveToObject(destination);
await sleep(2000);
await this.driver.buttonUp(0);`
I'm not sure what properties are on the source and destination objects you are using but here is an example of how I was able to get it to work using the same commands you are trying.
In my example I have a table with columns that can be re-ordered by dragging and dropping them wherever I want them to be. First I get the two column headers I want to switch
let docIdHeader = browser.element('div[colid="documentid1"]');
let pageCountHeader = browser.element('div[colid="_PAGE_COUNT1"]');
If I log these objects out to the console I can see the properties stored in them.
> docIdHeader
{ sessionId: 'e35ae3e81f1bcf95bbc09f120bfb36ae',
value:
{ ELEMENT: '0.3568346822568915-1',
'element-6066-11e4-a52e-4f735466cecf': '0.3568346822568915-1' },
selector: 'div[colid="documentid1"]',
_status: 0 }
> pageCountHeader
{ sessionId: 'e35ae3e81f1bcf95bbc09f120bfb36ae',
value:
{ ELEMENT: '0.3568346822568915-2',
'element-6066-11e4-a52e-4f735466cecf': '0.3568346822568915-2' },
selector: 'div[colid="_PAGE_COUNT1"]',
_status: 0 }
Now using the same technique you are using and the selector property off of these objects I can get it to work in two ways.
browser.dragAndDrop(docIdHeader.selector, pageCountHeader.selector);
Or
browser.moveToObject(docIdHeader.selector)
browser.buttonDown(0)
browser.moveToObject(pageCountHeader.selector)
browser.buttonUp(0)
I ran this in the REPL interface so I know it works as I could see each step being executed after I sent the commands. If you are not familiar with how to use the REPL I highly recommend learning. You can play around with commands in the console until you figure something out and then add those commands to your tests.
Also, as I stated in my comments above. dragAndDrop() and moveToObject() are going to be deprecated soon and you will likely see a lot of warnings about it when you use these. The correct way to implement a drag and drop action going forward is to use browser.actions(). Unfortunately, I don't have an example of how to do it that way as I haven't played with it yet. If no one provides an example by tonight I will try to get one together for you.
Even I faced this issue wherein the cursor doesn't move to the destination object after buttonDown and using moveToObject twice worked for me.
await this.driver.moveToObject(source);
await this.driver.buttonDown(0);
await this.driver.moveToObject(destination);
await this.driver.moveToObject(destination);
await this.driver.buttonUp(0);

Unbinding and rebinding DataTables search event results in null sSearch

I'm in a bit of a pickle with this one. I'm using jQuery DataTables 1.10.6, and I want to make it so that when the user stops typing (like maybe after 950 ms?), the search is performed. I kind of have it working, but since I'm using server-side processing, sSearch (the search parameter) returns null.
I'm guessing it has to do with the unbinding and re-binding, but I don't know how to make it so that sSearch is sent properly.
var delay = function () {
var timer = 0;
return function (callback, ms) {
clearTimeout(timer);
timer = setTimeout(callback, ms);
}
})();
$("div.dataTables_filter input").unbind();
$("div.dataTables_filter input").bind("keyup", function () {
alert(this.value);
delay(function () {
$("#MyTable").dataTable().fnFilter(this.value);}, 1000);
}
DataTables has an option to se delay, you can check it here
I found a deprecated plugin which is a key debounce delay: https://www.datatables.net/plug-ins/api/fnSetFilteringDelay
Even though it's stated that this won't work with 1.10+, there's a comment stating that a line change would allow it to work in 1.10+. So the following line:
anControl.unbind('keyup search input').bind('keyup search input', function() {
...would be replaced with:
anControl.off('keyup search input').on('keyup search input', function() {
I was also able to set the filtering delay timer in the calling argument. Works like a charm.

How to extend jQuery's animate-step function

Any ideas how to extend the step-function in jQuery 1.6+?
I've made a special-event to trigger a custom-event on each animated step. However since jQuery's animation method was changed, or rather the step function is not longer extendable ($.fx.step results in an empty object) is it impossible to extend it with your own things.
(function($){
var oldStep = $.fx.step._default;
$.event.special.animating = { };
$.fx.step._default = function( fx ) {
$(fx.elem).trigger('animating', fx);
oldStep.apply( this, arguments );
};
}(jQuery));
$('#foo').animate({width: 200});
$('#foo').bind('animating', function(e, fx){
console.log(fx);
});
Any ideas how to get this to work with newer jQuery versions?
Got it, in jQuery's updates-blog, this is already flagged to be commented.

How to use dojox/mobile/ScrollablePane Events

ScrollablePane in dojo mobile have some event that we can use as they have mentioned in their API documentation. I try to use the as follows.
leftPane.on("onTouchEnd", function(e){
alert("sss");
});
(leftPane is a ScrollablePane) This does not work. But this works when I use a event like "click". I search throughout the net for a example but didn't find a one. Can someone help me out here.
Thank you.
use:
aspect.after(leftPane, 'onTouchEnd', function(e) { });
dojo/on is tricky when it comes to the event naming - you could start by ditching the "on" prefix. Most likely, simply changing onTouchEnd to touchend would work
The Dojo event system changed significantly between 1.6 and 1.7. The new on function and the Evented mixin is the recommended way of handling events in widgets, but there are some backward-compatibility functions in the _WidgetBase class.
In short, you can either use the legacy dojo.connect function, the new aspect function (which implementes the "connect to normal javascript method" functionality of the old dojo.connect), or use the new on method in the _WidgetBase class that is a bridge between the two.
1. dojo.connect(leftPane, 'onTouchEnd', function(e) { });
2. aspect.after(leftPane, 'onTouchEnd', function(e) { }, true); // <-- the 'true' is important!
3. leftPane.on('touchend', function(e) { });
YMMV on (3) depending on whether the widget was updated to provide this bridging.

Where are working dojox.storage AMD examples?

I can't seem to find dojox.storage documented somewhere recently. Is dojox.storage broken in 1.7 (AMD)? It appears the unit-tests aren't even working. The example at /dojo-release-1.7.2-src/dojox/storage/tests/test_storage.html doesn't seem to work at all on FF or IE.
What is the recommended approach to using a local storage? In our case we'd like to use HTML5 storage that falls back on cookie storage when not available.
Below example from http://dojotoolkit.org/reference-guide/1.8/dojox/storage.html It's working on Dojo 1.7 and above.
dojo.require("dojox.storage");
var storageProvider=null;
dojo.addOnLoad(function(){
dojox.storage.manager.initialize();
storageProvider=dojox.storage.manager.getProvider();
storageProvider.initialize();
var myObject={key1:true};
storageProvider.put("myValue", myObject, function(status, keyName){
alert("value put in "+keyName);
});
});
According to http://dojotoolkit.org/reference-guide/1.8/dojox/storage.html and http://bugs.dojotoolkit.org/ticket/14465, dojox.storage isn't expected to work with AMD and won't be for a while.
That said, this did work for me in dojo 1.8.3:
require(["dojox/storage", "dojo/ready"], function (storage, ready) {
ready(function() {
var storageProvider = dojox.storage.manager.getProvider();
storageProvider.initialize();
var vals = storageProvider.get("InventoryMainSelectionHistory");
var i = 1;
});
});
As for DoJo 1.9.2, dojox.storage test (/dojox/storage/tests/test_storage.html) wasn't working. After nearer inspection it happened to be initialization issue in that particular code:
// wait until the storage system is finished loading
dojo.addOnLoad(function(){
// is the storage already loaded?
if(dojox.storage.manager.isInitialized() == false){
dojo.connect(dojox.storage.manager, "loaded", TestStorage, TestStorage.initialize);
}else{
dojo.connect(dojo, "loaded", TestStorage, TestStorage.initialize);
}
});
The listener has registered waiting for event "loaded" on dojo, that wasn't called in newer DoJo version. After changing the code:
dojo.addOnLoad(function(){
TestStorage.initialize();
});
the example functions (for LocalStorageProvider) in both FireFox and IE 10.