Try a lot of things before asking, but I still failed to load a sound as buffer in my Ionic project.
I don't know if this is a bug from my old firefox browser 26 (Fedora 18) or if I am doing it wrong.
Here my code, pretty much classic for loading arrayBuffer for web audio API with XMLHttpRequest():
var request = new XMLHttpRequest()
request.open('GET', './sound/mySound.ogg', true)
request.responseType = 'arraybuffer'
request.onload = function() {
audioCtx.decodeAudioData(request.response, function (buffer) {
mainBuffer = buffer
}, function (err) {
console.log(err)
})
}
request.send()
I get this warning message in console:
Les données passées à decodeAudioData possèdent du contenu de type
inconnu.
and err is undefined
Same piece of code works fine in an Apache server.
What am I missing here?
I try also something like this:
$http.get(url, { responseType: 'arraybuffer' }).success(function (data) {
audioCtx.decodeAudioData(data, function (buffer) {
mainBuffer = buffer
}, function (err) {
console.log(err)
})
}, function (err) {
console.log(err)
})
But still no luck. The file seems corrupted. So frustrating...
html5 audio tag returns the same error.
Is it a problem with the Ionic server?
Is there a way to solve this issue ?
Any advice would be very appreciate.
Just found a solution to my problem and make an answer to this similar question:
How do I load an AudioBuffer with Angular $http?
Based on the error message, it seems that your browser doesn't support ogg files. Try a different compression method for your audio file.
Related
I'm making a Flutter Web App which has to access the microphone and streams the audio data as an array of integers for further processing.
I already succeeded doing this in plain JavaScript.
Things I've tried:
The flutter_sound library, but I couldn't get it to work. I also can't find any working examples for that library.
dart:web_audio seems to be a thing, but apparently you can't even import it yet in normal Flutter Apps.
dart:js is what im trying to do right now. I was able to create an AudioContext with var audioContext = JsObject(context['AudioContext']);. However, after that I dont know what syntax can be used to transfer the JavaScript code into Dart. Here is what I'm doing in JavaScript:
function initAudio() {
try {
audioCtx = new AudioContext();
const GotAudioStream = function(stream) {
const audioSource = audioCtx.createMediaStreamSource(stream);
const audioProcessor = audioCtx.createScriptProcessor(bufSize, 1, 1);
audioSource.connect(audioProcessor);
audioProcessor.connect(audioCtx.destination);
audioStarted = true;
audioProcessor.onaudioprocess = function(e) {
checkAudioBuffer(e.inputBuffer);
};
};
navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(GotAudioStream);
}
catch (err) {
console.log(err);
}
}
Does anyone have experience with the dart:js library or another Idea on how to implement a simple (live!) audio stream in Flutter Web?
Regards,
Kaisky
I'm working on an ionic mobile application where I needed to read videos on streaming by providing the URI of the video online. So I used cordova-plugin-media-streamingplugin offered by cordova.
My problem is that: the window reading the video closes automatically after the video finishes, the user won't be able to play the video again in this window.
In the official documentation of the plugin [that i found here], there is an attribute called shouldAutoClosethat should be set to false to avoid that problem. But this didn't work for me.
Here is the code I used to play a video on streaming :
startVideo(item : Multimediasendtrust) {
let options = {
successCallback: () => { console.log('Finished Video') },
errorCallback: (e) => { console.log('Error: ', e) },
orientation: 'portrait',
controls: true,
shouldAutoClose: false
};
console.log('those are option ',options );
console.log('the link of the video ', item.url_media);
this.streamingMedia.playVideo(item.url_media, options); }
Can anyone help please. Thanks in advance.
I'm trying to implement ezar to ionic but can't use it. I did ionic cordova plugin add com.ezartech.ezar.videooverlay
window["plugins"].ezar
.initializeVideoOverlay(
function () {
window["plugins"].ezar.getBackCamera().start();
document.body.style.backgroundColor = 'transparent';
},
function (err) {
alert('unable to init ezar: ' + err);
});
It can't find ezar says undefined
I tried without window[] but couldn't succeed it also I can't import at ts file because its not installed as a component. Do you have any idea?
Thank you
This worked for me:
var win: any = window;
if (win.ezar) {
var ezar: any = win.ezar;
ezar.initializeVideoOverlay(
function() {
ezar.getBackCamera().start();
},
function(err) { alert(JSON.stringify(err));
}, {fitWebViewToCameraView: true});
} else {
alert('Unable to detect the ezAR plugin');
}
Try window["ezar"] in place of window["plugins"].ezar
Worked for me (although getting ezAR to work with ionic 3 in general is quite difficult with the lack of documentation)
The below lines of code has been written by one of my colleague. This code is working for me, but I am actually looking for an explanation for each line. specially It is confusing with callback. It will be great if anyone can comment each line.
Thanks
function startApp(done) {
console.log("Inside startApp");
browser.get(baseUrl).then(
function (success) {
console.log("LOG MESSAGE - URL launched successfully");
browser.waitForAngular();
done();
},
function (failure) {
console.log("LOG MESSAGE - Fail to launch URL");
done(failure);
}
);
}
I want to get some json object from a remote server.
Here is the simplest html you can imagine:
<div id="getHotels" data-theme="e" data-role="button">Get hotels</div>
<ul id="bringHotels" data-role="listview"></ul>
and here is the javascript:
$("#getHotels").click(function(){
$.getJSON("/services/apexrest/Hotels", function(obj){
$.each(obj,function(key,value){
$("#bringHotels").append("<li>"+value.Hotel_Name__c+"</li>");
});
});
});
i have never used the getJSON method but it seems to be quite clear, despite that it doesnt work and I checked the directory - there really is JSON array. So, if I am doing it wrong, please correct me, thank you.
There are no enough informations about the problem to solve it...
It could be a problem in the URL you pass to getJSON. Try to change the first slash with a ./, or use other callbacks to obtain more debug infos:
$.getJSON("example.json", function() {
alert("success");
})
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });