[ 
https://issues.apache.org/jira/browse/CB-11611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15401091#comment-15401091
 ] 

jcesarmobile commented on CB-11611:
-----------------------------------

I've used this code

{code}
function onAudioInput( evt ) {
            console.log( "Audio data received: " + evt.data.length + " samples" 
);
            var i=0;
            while(i<evt.data.length){
                if(evt.data[i]>0.05){
                    navigator.vibrate(10);
                    console.log('vibrate');
                }
                i += evt.data.length / 10;
            }
        }
        
        // Listen to audioinput events
        window.addEventListener( "audioinput", onAudioInput, false );
{code}

And this on device ready

{code}
// Start capturing audio from the microphone
        audioinput.start({
                         // Here we've changed the bufferSize from the default 
to 8192 bytes.
                         bufferSize: 8192 
                         });
{code}

On Android it's working fine, if I speak making the value of vt.data[i]>0.05 it 
vibrates.

Sadly on iOS I don't have any device with vibration to test (iPods and iPads 
don't vibrate).
I can see the console.log('vibrate'); when I speak making the value of 
vt.data[i]>0.05


Just adding this information in case somebody with an iPhone can reproduce.

BTW, changing the vibrate code to make the camera sound (from 
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); to 
AudioServicesPlaySystemSound(1108);), makes the sound whenever the condition is 
true.

> iPhone doesn't vibrate in my code
> ---------------------------------
>
>                 Key: CB-11611
>                 URL: https://issues.apache.org/jira/browse/CB-11611
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Vibration
>            Reporter: zhuisui
>
> I write some code to implement a feature.
> I inspect every element of array and if some satisfy condition I call 
> {{vibrate}}.
> code like this
> {code:javascript}
> document.addEventListener('data', v, false);
> function v(arr){
> var i=0;
> while(i<arr.length){
> if(condition){
> vibrate(10);
> }
> i += arr.length / 10;
> }
> }
> {code}
> But it doesn't vibrate, until event {{data}} doesn't be dispatched.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to