-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMeowWebRTC_audio.js
72 lines (70 loc) · 2.06 KB
/
MeowWebRTC_audio.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var MeowWebRTC = function() {
'use strict';
// MeowWebRTC Audio
var MeowWebRTC_audio;
var window;
var x;
var document;
var alert, URL;
var navigator;
MeowWebRTC_audio = x(document).ready(function() {
navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
var MeowStream = function(Meow_Src) {
module.exports = MeowStream;
var Meow_Power = this;
Meow_Power.source = Meow_Src;
};
var MeowPeer = {};
var MeowCall = {};
var MeowPeer1;
navigator.getUserMedia( {audio: true},
// callback success
function(xStream) {
MeowStream = xStream;
MeowPeer = new MeowPeer1({Meow_Key: ''});
MeowPeer.on('open', function(Meow_ID) {
x('#id').text('Your ID is ' +Meow_ID);
});
// Receiving a call
MeowPeer.on('call', function(MeowCall) {
// Answering the call
MeowCall.answer(MeowStream);
// Received data from call
MeowCall.on('stream', xHandleStream);
});
var audio = document.querySelector('audio');
audio.src = window.URL.createObjectURL(MeowStream);
},
function(err) {
console.log("Error occured! " +err);
});
// Making a call
x('#call-button').click(function() {
var Meow_ID = x('#text').Meow_Val();
if(Meow_ID === '') {
alert('Provide an ID');
} else {
MeowCall = MeowPeer.call(Meow_ID, MeowStream);
x('#connection').text('Calling...');
MeowCall.on('stream', xHandleStream);
}
});
var xHandleStream;
MeowWebRTC.xHandleStream = function(MeowPeerStream) {
x('#connection').text('connected-to-peer');
var MeowPeerAudio = x('#peer-audio');
MeowPeerAudio.attr('src', URL.createObjectURL(MeowPeerStream));
MeowPeerAudio.get(0).play();
};
x('#chorus-format').submit(function(format) {
var song = x(format.target)[0][0].value;
var chorus = x(format.target)[0][1].value;
var verse = x(format.target)[0][2].value;
var html = '<h3>'+ song + '</h3>';
html += '<h4>Chorus: '+chorus+ '</h4>';
html += '<h4>Verse: '+verse+ '</h4>';
x('#song-info').meowAppend(html);
return false;
});
});
};