Cannot call method 'hasAudio' of undefined
I've Installed new version of licode, and write some code for recording of video.
var DEMO = {}; var room = null; var localStream = null; var recordingId = null;
DEMO.init_demo = function (my_name) {
localStream = Erizo.Stream({audio: true, video: true, attributes: {name: my_name}});
DEMO.chat_stream = localStream;
DEMO.create_token(my_name, "presenter", function (response) {
var token = response;
console.log(token);
room = Erizo.Room({token: token});
localStream.addEventListener("access-accepted", function () {
room.connect();
localStream.show("my_video");
});
localStream.init();
});
};
DEMO.start_recording = function() { room.startRecording(localStream, function(recordId, error) { recordingId = recordId; if (recordingId === undefined){ console.log("Error", error); } else { console.log("Recording started, the id of the recording is ", recordingId); } }); };
DEMO.stop_recording = function() { room.stopRecording(recordingId, function(result, error){ if (result === undefined){ console.log("Error", error); } else { console.log("Stopped recording!"); } }); };
////////////////////////////////
when I run DEMO.start_recording function, I got errors in server side. Below is logs;
2016-02-13 16:59:37.889 - DEBUG: ErizoController - OK, Valid token
2016-02-13 16:59:45.427 - INFO: ErizoController - erizoController.js: Starting recorder streamID undefinedurl /var/nodeapp/recorded/299578916048631100.mkv
Missing error handler on socket.
TypeError: Cannot call method 'hasAudio' of undefined
at Socket.
////////////////////////////////////////////
Hope let me know what I wrong.
And I tried to get ID of localstream in above code.
localStream.addEventListener("access-accepted", function () {
room.addEventListener("room-connected", function (roomEvent) {
console.log(localStream.getID());
});
room.connect();
localStream.show("my_video");
}
//////////////////////////////////////////
localStream.getID() return undefined.
It was my fault. I've modified code as below;
DEMO.init_demo = function (my_name) {
localStream = Erizo.Stream({audio: true, video: true, attributes: {name: my_name}});
DEMO.chat_stream = localStream;
DEMO.create_token(my_name, "presenter", function (response) {
var token = response;
room = Erizo.Room({token: token});
localStream.addEventListener("access-accepted", function () {
var subscribeToStreams = function (streams) {
for (var index in streams) {
var stream = streams[index];
if (localStream.getID() !== stream.getID()) {
room.subscribe(stream);
}
}
};
room.addEventListener("room-connected", function (roomEvent) {
console.log('room-connected');
room.publish(localStream);
subscribeToStreams(roomEvent.streams);
});
room.addEventListener("stream-added", function (streamEvent) {
console.log('stream-added');
var streams = [];
streams.push(streamEvent.stream);
subscribeToStreams(streams);
});
room.connect();
localStream.show("my_video");
});
localStream.init();
});
};
Now it worked.
Is the recording is also gets worked or not. I am also facing the issue hasAudio() method is undefined while doing a recording. Please explain me how to fix the problem for recording ?