mozChannels/mozSampleRate is undefined - javascript

I am using the this within an audio experiment of mine.
audiometa: function(){
channels = audio.mozChannels;
rate = audio.mozSampleRate;
frameBufferLength = audio.mozFrameBufferLength;
fft = new FFT(frameBufferLength / channels, rate);
},
For some reason, mozChannels/mozSampleRate and mozFrameBufferLength is undefined using the latest version of Firefox. Reading the cos, I can't explain myself, why this could happen.
Is there something within the about:config page which I need to turn on? (Have tried it local and on a webserver)
By the way, I am using this example.
https://wiki.mozilla.org/Audio_Data_API#Reading_Audio
Thanks

It looks like Firefox no longer supports mozChannels, mozSampleRate and mozFrameBufferLength. That would cause an undefined error. The link to the doc you provided has a note that says that API has been deprecated in favor of the W3C Web Audio API. And I searched through the Firefox codebase here:
https://dxr.mozilla.org/mozilla-central/source/
And those properties do not appear in the Firefox code. I suggest you try using the W3C Web Audio API:
https://webaudio.github.io/web-audio-api/
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API

Related

localForage setItem/getItem unreliable in Firefox / FireStorage Plus

I am loading a local instance of localForage and using it with Promise chains to save basic data. A simple example:
localforage.getItem("sellerExtension").then(function(sellerExtension) {
if ((!sellerExtension) || (sellerExtension.length < 3)) {
var sellerExtension = $('input#sellerExtension').val();
if ((sellerExtension) && (sellerExtension.length > 3)) {
localforage.setItem('sellerExtension', sellerExtension).then( function() {
});
}
}
});
The problem comes when I go into the FF Dev-Tools to check FireStorage Plus! and see nothing related to the saved/set data. BUT I do in Chrome just fine. There should be several saved items.
I'd been replacing localStorage (just for Firefox ugh) and am somewhat perplexed why thier own wrapper isn't showing in this FF specific extension for accessing the local DB instances. It shows key, getItem, clear and all, however.
Any ideas why this is happening? I fully expected to see something, and am looking in the right spot, I believe. (Screenshot below) It doesn't seem to be loading the data from a .getItem request, either.
I am using some AJAX to access other files in a sub-directory which handles localForage, but am on the same domain/port. Could I somehow be working in another scope? How would I know?
Thanx MUCH for any assistance!
And in Chrome I see it all...
BUT not in FF in any of the Scopes listed...
Could the problem be that it's localStorage and not localForage as you have in your code?
Did you notice that in your screen shot, the Firebug tab says localStorage on it?
Extensions like Firestorage Plus! and simplesession are NOT reliable when looking for data being set with localForage!!! The key (pun intended) is to use the Firefox built-in Inspector.
I could NOT find this in my FF after adding extensions, but I had the FF Dev Edition, ran that, enabled the Storage tool in config options, and bam, there they ALL were!! Hope this helps someone else out.
I "believe" that if you set data on a different page/file, those extensions wont see these values, only the orginial file/page's getItem data.

Where in metadata of a video in html5 is the fps saved?

In order to fully implement my custom html5 video player, I need the the exact frame rate of a video. However I have not been able to find it yet and am using a standard value of 25.
Typically videos have a frame rate value in meta-data so I accessed meta-data using something like this:
var vid = document.getElementById("myVideo");
vid.onloadedmetadata = function(e) {
console.log(e);
};
However I can't find frame rate here. Maybe I am not reading metadata at all.
I can use your help.
Thanks!
Try https://mediainfo.js.org (github)
It works on ui only, no backend needed
I just implemented it and it looks like it worked perfectly fine (at least in Chrome v 70.0.3538.77) for gettting wide media information
It looks like modern browsers beginning to work with some binary libraries
I'm 95% sure the standard html5 video api does not expose the fps information, from what I've read in the past months - other apis like MPEG-DASH and jwplayer do present more / different data.
Your best bet would be to snoop around w3schools.com/tags/ref_av_dom.asp and similar mdn pages.
You can calculate this in realtime yourself and it should work most of the time but I can imagine there's a case or two when it wouldn't. Look at PresentedFrames and then do something like:
fps = video.time / PresentedFrames
view more about PresentedFrames here (currently proposal) and similar attributes at the same link.
mediainfo.js works pretty good - even if used locally in a browser using 'http(s)://'.
To use it locally, just make sure you also download the accompanying mediainfo.wasm and put it into the same directory as mediainfo.min.js.
Alternatively you can install media-info using npm.
The only caveat is, that it doesn't run from the 'file://' protocol.

Ideas needed. Javascript+XPCOM+C++ add-on

So, there is a WebRTC inside Firefox and there is a convenient class for making RTC communication possible called RTCPeerConnection which can be instantiated and used from the JavaScript app. You can find some decent example of it on [1].
And here am I with my custom transport (if you're interested - [2]) would like to use it for RTC communication. Briefly, I need to "substitute" the transport layer of WebRTC engine by my custom transport while providing the same RTCPeerConnection-like JavaScript interface for the user. And preferably, it should not look like custom build of Firefox (no patches).
So I've come up with the idea of extension, which will be written in C++ (since it need to be linked with WebRTC library and my custom transport library) and somehow will expose its interface to Javascript. And I've found XPCOM which, as I thought, can provide me this.
So I've started to fight with out-dated and sparsed info on this topic and after 3 days of struggling finally ended up with builded add-on. Unfortunately, I can't access it from Javascript, because of Javascript's "Components.classes is undefined" error. And it seems that there is no way to access it at all. Or I'm wrong on that?
Here is Javascript:
function check()
{
console.debug("checking...");
const {Cc,Ci,Cu} = require("chrome");
var rtc = Components.classes["#named-data.net/ndnrtc;1"].createInstance();
rtc = rtc.QueryInterface(Ci.ndINrtc);
console.debug("rtc: "+rtc);
}
My component is visible with XPCOM Viewer addon and the code above I can execute in the console while empty page is open in Firefox.
Given all that, I would like to ask Firefox experts regarding possible approaches which I can take in order to implement my idea.
Thank you in advance
1 https://apprtc.appspot.com/
2 http://named-data.net
Finally, I've figured out one possible solution for that and describe it in my post

Why CreateJS code not working in firefox?

Have exported my flash cs6 game using createjs using "toolkit for createjs". All sounds exported to directory successfully.
Following code calls sounds
var manifest = [
{src:"sounds/cutter.wav", id:"cutter"}
];
var loader = new createjs.PreloadJS(false);
loader.installPlugin(createjs.SoundJS);
loader.onComplete = handleComplete;
loader.loadManifest(manifest);
function playSound(name, loop) {
createjs.SoundJS.play(name, createjs.SoundJS.INTERRUPT_EARLY, 0, 0, loop);
}
chorme and opera plays sound correctly but firefox.
Thanks in advance :)
I would recommend trying the latest code available at http://www.soundjs.com. You'll also find helpful tutorials and examples that work in firefox. It doesn't offer direct toolkit support, but it can help you understand what the exported code is doing and how to alter it.
My best guess without seeing the code in context is you are trying to call play without waiting for load to complete. This creates a race condition, where sometimes if the sound is cached it will work, and other times it will fail.
It's also possible that it has something to do with the wav encoding. With mp3s we've found you mostly need to stick to default encoding to ensure browsers can actually play the audio. You might also want to consider using mp3 and ogg files for the broadest audio support.
Hope that helps.

jQuery.data() works in Mac OS WebKit, but not on iPhone OS?

I'm playing around with jQTouch for an iPhone OS app that I've been toying with off and on for a while. I wanted to try my hand building it as a web app so I started playing with jQTouch. For reference, here is the page+source (all my code is currently in index.html so you can just "View Source" to see it all):
http://rpj.me/doughapp.com/wd/
Essentially, I'm trying to save pertinent JSON objects retrieved from Google Local into DOM objects using the data() method (in this example, obj is the Google Local object):
$('#locPane').data('selected', obj);
then later (in a different "pane"), retrieving that object to be used:
$('#locPane').bind('pageAnimationEnd', function(e, inf) {
var selobj = $(this).data('selected');
// use 'selobj' here ...
}
In Chromium and Safari on the desktop OS (Snow Leopard in my case), this works perfectly (try it out).
However, the same code returns undefined for the call to $(this).data('selected') in the second snippet above. I've also tried $('#' + e.target.id).data('selected') and even the naive $('#locPane').data('selected'). All variants return undefined in the iPhone OS version of WebKit, but not on the desktop.
Interestingly, the running this on Mobile Safari in the iPhone Simulator fails as well.
If you look at the full source, you'll see that I even try to save this object into my global jQTouch object (named jqt in my code). This, too, fails on the mobile platform.
Has anyone else ever ran into this? I'll admit to not being a web/javascript programmer by trade, so if I'm making an idiot's error please call me out on it.
Thank you in advance for the help!
-RPJ
Update: I didn't make it clear in the original post, but I'm open to any workaround if it works consistently. Since I'm having trouble storing these objects in general, anything that allows me to keep them around is good enough for now. Thanks!
Have you tried using HTML5 data-ref attributes? The data has to be stringified, but you can just do
$('#locPane').attr('data-selected', "somestring");
and still have valid HTML5 markup.
As far as I can tell there seems to be a bug in Mobile Safari storing objects like this. So what I did was to simply store the components of the object in the documents data store.
$(document).data( "lessonCode" , lesson.lessonCode);
$(document).data( "question" , lesson.question);
$(document).data( "answer" , lesson.answer);

Categories