Languages

Menu
Sites
Language
way to intercept audio stream

Hello,

I would to ask if there is any way/API to intercept an audio stream with the Gear2 device?

Because I tried to do it with this code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="A single-page template generated by Tizen Wearable Web IDE"/>

    <title>Tizen Wearable Web IDE - Tizen Wearable - jQuery</title>

    <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="js/main.js"></script>
    <link rel="stylesheet" href="css/style.css" />
    <script>
       	function SuccessCallback(stream) 
   		{   
      		var URL = window.webkitURL;
      		document.getElementById("videoPlay").src =  URL.createObjectURL(stream);                     
   		}    
	</script>
    <script>  
   		function getVideoStream() 
   		{
      		navigator.webkitGetUserMedia({audio: true}, successCallBack, errorCallBack);                     
   		}
	</script>
	
	
</head>
<body>
  <video id="videoPlay" src="" autoplay controls></video><br/>
   <input type="button" value="START" onclick="getVideoStream();" id="btnStart">
</body>
</html>

 

it always told me: "index.html (23) :ReferenceError: Can't find variable: successCallBack"

Thanks in advance.

Edited by: karray gargouri on 29 May, 2014

Responses

5 Replies
Alex Dem

Hi,
Even at first sight 'SuccessCallback' is not equal 'successCallBack'
Please check uppercase and lowercase symbols: 's' and 'b'
Alexey.

David Jay

I'm also trying to solve this problem. The following implementation works on the web, but not on the Gear:

http://jsfiddle.net/davidgljay/metJZ/6/

[code]

navigator.webkitGetUserMedia({
    audio: true
}, function (stream) {
    var audioContext = new window.webkitAudioContext();
    var audioInput = audioContext.createMediaStreamSource(stream);
    var analyser = audioContext.createAnalyser();
    console.log(audioInput);
    audioInput.connect(analyser);
    var frequencyData = new Uint8Array(analyser.frequencyBinCount);
    var value = 0;

    setInterval(function () {
        value = 0;
        analyser.getByteFrequencyData(frequencyData);
        for (i = 0; i < frequencyData.length; i++) {
            value += frequencyData[i];
        }
        console.log(value);
    }, 500);
}, function (err) {
    console.log('Got an error: ' + err.name)
});

[/code]

The analyser turns up all '0's, as if the audiostream isn't connected to the mic. Any help would be greatly appreciated.

 

karray gargouri

Hello,

Thank you for your reply.

I didn't figure out how it does it, really works.

I made an "alert (value);" instead of "console.log(value);"  and I got many alerts of numbers (after allowing the access to the mic).

Could you explain more the process, thx again!

Best regards.

David Jay

This is firing off a number every 500ms that correllates to the amount of noise that the mic has picked up. If you are getting all zeros that's bad, it means the mic is off. If you get all number's that's good, it means the mic is on and you've got the stream. Are you getting numbers on a Gear 2?

karray gargouri

Hi,

- I tested over the browser: it works.

- Over the Tizen wearable Emulator: it shows 0.

- Over the Gear2 device: it hadn't been even deployed (and the IDE console shows nothing as error)!!