简体   繁体   English

如何在 xamarin 形式的 android 中使用 wavesurfer.js?有人知道吗?

[英]How to use wavesurfer.js in xamarin forms android?Can anybody have idea?

Right now im trying to load file from internal device,现在我正在尝试从内部设备加载文件,

Working code:
enter code here
    wavesurfer.load('file:///assests_content/rooster.wav');
        alert('hi2');

Not working code:不工作的代码:

    wavesurfer.load('file:///storage/emulated/0/new/rooster.wav');
        alert('hi2');

This code works perfect, I fixed it using loading the file as the blob.这段代码完美无缺,我使用加载文件作为 blob 修复了它。

 "<html> <head> <script src=""https://unpkg.com/wavesurfer.js""></script> <script src=""wavesurfer.spectrogram.js""></script> </head> <body> <h1>Xamarin.Forms</h1> <p>Welcome to WebView.</p> <div id=""waveform""></div> <div id=""spectrogm""></div> <div id=""MyTest"">my divs</div> <script> try{ alert('hi'); var wavesurfer = WaveSurfer.create({ container: '#waveform', waveColor: 'violet', progressColor: 'purple', plugins: [ WaveSurfer.spectrogram.create({ wavesurfer: wavesurfer, container: ""#spectrogm"" }) ] }); alert('hi2'); } catch(err) { alert(err.message); } function readTextFile(file) { try { var blob = null; var rawFile = new XMLHttpRequest(); rawFile.open(""GET"", file); rawFile.responseType = ""blob"";//force the HTTP response, response-type header to be blob rawFile.onload = function() { blob = rawFile.response;//xhr.response is now a blob object alert('blob'); wavesurfer.loadBlob(blob); } rawFile.send(); alert('completed'); } catch(err) { alert('error'); alert(err); } } readTextFile('file:///storage/emulated/0/new/rooster.wav');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM