Вход Регистрация
Файл: voice/js/app.js
Строк: 120
<?php
import
('./settings.js').then(Fn => {
    Fn.
buttonShow('block''''''''block');
    
document.querySelector('#voicePanel').addEventListener('click'=> {
        Fn.
buttonShow('''''''block''''block');
        
navigator.mediaDevices.getUserMedia({
            
videotrue,
            
audiotrue
        
}).then(stream => {
            Fn.
buttonShow('''block''''block''''');
            const 
mediaRecorder = new MediaRecorder(stream);
            
import('./storage.js').then(Df => {
                
Df.iconsDefaultSele(stream)
            });
            
document.querySelector('#voiceStart').addEventListener('click'=> {
                
context = new AudioContext();
                
src context.createMediaStreamSource(stream);
                
analyser context.createAnalyser();
                
src context.createMediaStreamSource(stream);
                
src.connect(analyser);
                
let data e.target.attributes;
                
window.currentUser = {
                    
contactdata.ank.nodeValue
                
};
                try {
                    
mediaRecorder.start();
                } catch(
e) {}
                
displayAnalyserTime('true');
                
recordStopTime();
                Fn.
buttonShow('''''block''block''''''''block');
            });
            
document.querySelector('#voiceEnd').addEventListener('click'=> {
                if(
mediaRecorder.state === 'recording'stream.getTracks().forEach(track => track.stop());
            });
            
let audioChunks = [];
            
mediaRecorder.addEventListener("dataavailable"=> {
                
displayAnalyserTime('false');
                
audioChunks.push(e.data);
            });
            
mediaRecorder.addEventListener("stop"=> {
                const 
audioBlob = new Blob(audioChunks, {
                    
type'audio/ogg'
                
});
                
let formData = new FormData();
                
formData.append('data', [window.currentUser.contact,
                    
localStorage.getItem('voiceAudio') !== null 'audio' 'video'
                
]);
                
formData.append('voice'audioBlob);
                
recordSendBlob(formData);
                
audioChunks = [];
            });
            
recordStopTime = () => {
                
setTimeout(() => {
                    if(
mediaRecorder.state !== 'inactive'stream.getTracks().forEach(track => track.stop());
                }, Fn.
timeEnd)
            };
        }).catch(
error => {
            Fn.
buttonShow('''''''block'''''JSON.stringify({
                die: 
'block',
                
text: Fn.answErr error.message
            
}), '');
        });
    });
    
recordSendBlob form => {
        Fn.
buttonShow('''''''block''''block');
        
fetch(Fn.url, {
            
method'POST',
            
headers: {
                
contentType'applicationjson'
            
},
            
bodyform
        
}).then(response => response.json()).then((ansver) => {
            
showPlayAudio(ansver)
        }).catch((
err) => {
            
console.log(`post: ${err}`)
        })
    }
    const 
showPlayAudio ansver => {
        Fn.
buttonShow('''''''block'''''JSON.stringify({
            die: 
'block',
            
textansver
        
}), '');
        
setTimeout(() => {
            
document.location.reload(true)
        }, 
1000);
    };
    
displayAnalyserTime = (a) => {
        if(
=== 'false'context.suspend().then(() => {});
        
context.currentTime.toFixed(0)
        
Math.floor(60);
        
Math.round((60 m) * 60);
        
voiceTime.textContent = (10 "0" m) + ":" + (10 "0" s) + ":" + (((context.currentTime.toFixed(1) - m) * 9).toFixed(2)).split('.')[1];
        array = new 
Uint8Array(2);
        
analyser.getByteFrequencyData(array);
        for(var 
01i++) {
            
tim = (array[i] / 3.2808);
            
document.getElementById("voiceAnalyser").style.width = `${tim}px`
        };
        
requestAnimationFrame(displayAnalyserTime);
    }
}).catch(
err => {
    
console.log(`all:  ${err}`);
});
?>
Онлайн: 5
Реклама
Игры между пользователями