Chrome/Webkit audio tag bug? - audio

I'm trying to get HTML5's audio tag to work in Chrome. The following code works flawlessly in Firefox, any ideas why it isn't working in Webkit?
<html>
<head>
<script type="text/javascript">
function init(){
audio = new Audio("chat.ogg");
audio.play();
}
</script>
</head>
<body onload="init()">
</body>
I should also note that I tried this with an mp3 as well. Regardless of what format, whenever .play() is called on audio, Chrome responds with "undefined".

Bug in Chrome, possibly Webkit as well:
http://code.google.com/p/chromium/issues/detail?id=25972
Short audio files won't play.

Try to host your audio file somewhere and try this:
audio = new Audio('http://www.yourhosting.com/chat.ogg');
audio.play();

Are you using the release version of Chrome? With the current dev build on Linux[1], I get the same behavior as FF 3.7 alpha (well, once I unblocked it with noscript) and SeaMonkey 2.0; that is, the Ogg file plays, although not even the default controls appear. If it is a bug in Chrome or Webkit, it is apparently fixed for the next version.
[1] Chrome: 5.0.342.1 (Official Build 40461) dev, Webkit: 533.2

Related

”//…” in <script> tag is interpreted as “file://” in electron

I'm trying to include external AddThis widget in Electron.
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxxxxxxxxxxxxx"></script>
The issue is that
// in <script> tag is interpreted as file://.
And the app errors with
GET file://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxxxxxxxxxxxxx net::ERR_FILE_NOT_FOUND
This can be easily fixed by adding http(s): before //. But huge mess happens if included js includes js'es starting with //. For example, addthis_widget.js includes 36 relative URLs starting with //
Such behavior takes place, because base URL in electron started with file: when application loaded: mainWindow.loadUrl('file:///index.html'). Then the relative URLs starting with // automatically resolved to file: and not http(s): But its not very clear how to revert things back.
Kindly help.
Adding js directly to the app is not an option, since AddThis modifying remote script(s) too often.

Playing .mp3 file in WP8 device not working

I am using following example to record an audio on Windows 8 app: http://visualstudiomagazine.com/articles/2013/03/21/audio-in-a-windows-store-app.aspx. It uses the Windows Runtime Media API to record audio.
The example works nice but I have a problem. I use the example to record an audio, but if I try to play the recorded audio in a Windows Phone 8 device (tested on Nokia Lumia 820 and 920) using MediaElement control it doesn't work (I hear some noice similar to an alien conversation). It does work correctly on the WP8 emulator.
I have also tried to record an audio using the Sound Recorder app that comes with Windows 8 and I have the same problem: it doesn't hear correctly on Nokia Lumia 820 and 920.
This is the code I use the play the audio file in XAML:
MediaElement Name="media" AutoPlay="True" Source="XXX.mp3"
Do you have any idea why?
Many thanks.
As I, and many, many others have posted on Stack Overflow already, the Media Element is really buggy and is not suggested for playing any source that is dynamic.
Instead, follow this blog post that I wrote on playing sound effects on the Windows Phone
Playing SFX on The Windows Phone
This is the executive summary of the post
static Stream stream1 = TitleContainer.OpenStream("soundeffect.wav");
static SoundEffect sfx = SoundEffect.FromStream(stream1);
static SoundEffectInstance soundEffect = sfx.CreateInstance();
public void playSound(){
FrameworkDispatcher.Update();
soundEffect.Play();
}

Node-Webkit read MP3 files

I use the audio class to read MP3 file thanks to a little trick : replacing the ffmpegsumo.so of Node-Webkit with the chromium one. This enable the reading of MP3 on Windows but doesn't works on Mac OS. Does anyone know why ?
Here's the code :
player = new Audio()
player.src = '/path/to/the/audio.mp3';
player.play();
This seems to be dependant upon the dll/so being a 32 bit version. I am guessing that is why copying the file from Chrome doesn't work correctly for most people ( my 3 year old phone is the only 32-bit device I have left ).
I keep seeing this link --
https://github.com/rogerwang/node-webkit/wiki/Support-mp3-and-h264-in-video-and-audio-tag
.. but it is a blank page. I am guessing it was deleted since the info was likely not current or correct.
This issue thread has links to some rebuilt ffmpegsumo libraries for both Mac and Windows --
https://github.com/rogerwang/node-webkit/issues/1423
The alternative appears to be rebuilding ffmpegsumo, this thread has some config for doing that -- https://github.com/rogerwang/node-webkit/issues/1208
I am still confused about the licensing on it after you build the library, so that is probably worth some research. Everything about mpeg4-part10 is copyrighted and heavily patent encumbered. I think we all need to get smart enough to stop using mp4/h.264. Before I got this working correctly on node-webkit, it was easier to use ffmpeg to transcode the video to an ogv container using Theora and Vorbis codecs. At this point it seems like iOS is keeping h.264 alive, when it should probably die the horrible death it has earned.

Jplayer 'play' command after 'pause' with time

Hello i am using jplayer for my solution. I load the media and on ready i use ('pause', time) command.
After that if i use a ('play') command my media starts playing from the beggining.
Is there something i do wrong as on jplayer's dev guide it is said on the play method:
"Open media will play from where the play-head was when previously paused using jPlayer("pause", [time])."
I encountered similar problem, when dealing with lost connection. jPlayer resumed playback from the beginning when a .play() method was called. So, at some point (in my case it was the error handler) I was executing $("#jquery_jplayer_1").jPlayer("play", event.jPlayer.status.currentTime);. It gets current position and orders jPlayer to play from that exact position. Works flawlessly for me.
But, please, provide some code, maybe your problem is completely different.

Single-file app with xulrunner - possible?

I have tried to mess with xulrunner before, and now I'm trying once again :)
The "real" tutorial (Getting started with XULRunner - MDN) does, in fact, show that one is supposed to have application.ini and other files (possibly zipped as .xpi, which then requires --install-app ...), and then the call should be like:
xulrunner `pwd`/application.ini
... however, I'd like an easier way to start up - and hence, my hope for single-file XUL application approach :) (A good note here is that one also cannot use the zipped .xpi as an argument to xulrunner, see XULRunner question - DonationCoder.com)
The thing is, I am almost 100% certain that at some point in the past, I have used a simple single-file XUL application, as in (pseudocode):
xulrunner my-xul-app.extension
... but I cannot remember how it went :) So, was that possible with xulrunner, or only with firefox?
As far as I can remember, I used something like a 'my-xul-app.xul' file (as the single-file application), which would specify only, say, a window with a single button (that couldn't really do anything due to lack of javascript) - and I'd like to repeat the same thing now, to refresh my memory (unless I confused something from back then :))
First of all, I found HOWTO: Getting Started with Linux Standalone Apps using XUL - Ubuntu Forums (2007), and I modified the example.xul file used there as:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
id = "myapp"
title = "SQLite Example"
height = "420"
minHeight = "420"
width = "640"
minWidth = "640"
screenX = "10"
screenY = "10"
sizemode = "normal"
xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
<spacer style = "height: 4px; cursor: default;" />
</window>
and I'm trying to "run" this as recommended in link, with:
firefox -no-remote -chrome file:$PWD/example.xul
... and what happens is that Firefox opens, with window size being like 1x1 pixels; if you can find the handle, you can stretch the window, and read:
Remote XUL
This page uses an unsupported technology that is no longer available by default in Firefox.
Ouch :( Answers to this (like How do I fix the Remote XUL error I get when using Firefox 4.x and the Webmail Advanced Interface?) seem to be related to actual remote xul (and recommend a plugin to handle that); but what I want is simply to run a file locally?! Where did the "remote" part come from?
Also, seeing the firefox switch '-app' (Using Firefox 3 as a XUL runtime environment); although it refers to an application.ini, I tried this:
firefox -no-remote -app $PWD/example.xul
... and Firefox just started as usual.
Btw, I cannot see neither -app nor -chrome command line options in firefox --help ;)
But actually, I do not really want to use firefox as an engine - just the xulrunner; and I tried the Firefox approach because I thought it is more-less the same as xulrunner; turns out it isn't (even if you use application.ini: Why does 'firefox -App application.ini' and 'xulrunner application.ini' behave differentely? | Firefox Support Forum):
In any case, if I run just xulrunner (as I wanted to), I get:
$ xulrunner example.xul
Error: App:Name not specified in application.ini
So, I can see everything points to "single source file" app not being possible with xulrunner - but I just wanted to make sure (in case I missed some obscure tutorial :) ). And if it isn't - does anyone remember if it was possible at a previous point in time?
PS:
$ firefox --version
Mozilla Firefox 7.0.1
$ xulrunner --version
Mozilla XULRunner 2.0 - 20110402003021
$ uname -r
2.6.38-11-generic
$ cat /etc/issue
Ubuntu 11.04 \n \l
I don't believe you could ever create single-file XULRunner applications. The -chrome <...> parameter probably used to work, I guess the "Remote XUL" error comes from the fact that the URL is file://, not chrome://.
You could use something like the Live XUL Editor in the Developer Assistant (formerly Extension Developer's extension) to test XUL quickly.
The general idea I hear these days is that you should write HTML5 instead, whenever you can, since it is more actively developed, more well-known technology with less incompatible changes and better tooling...
Here is the answer I wrote for another related question, reproduced here because it may help someone who want to know how to package their XUL application.
It is too bad that xulrunner can not run a zipped .xpi or .xulapp directly, but it is possible to package most of your .js, .xul, .css and .png files into a jar and wrap everything up with a private copy of xulrunner, without having to run --install-app
These are the steps I went through to package our XUL application.
The first step is to put all your files (except application.ini, chrome.manifest, and prefs.js) into a .jar file like this (all of this was carried out under Windows, make appropriate adjustments for Linux and OSX)
zip -r d:\download\space\akenispace.jar * -i *.js *.css *.png *.xul *.dtd
Then in d:\download\space, layout your files as follows:
D:\download\space\akenispace.jar
D:\download\space\application.ini
D:\download\space\chrome.manifest
D:\download\space\defaults
D:\download\space\defaults\preferences
D:\download\space\defaults\preferences\prefs.js
The content of the files are as follows
application.ini
[App]
Vendor=Akeni.Technologies
Name=Akeni.Space
Version=1.2.3
BuildID=20150125
Copyright=Copyright (c) 2015
ID=space#akeni.com
[Gecko]
MinVersion=1.8
MaxVersion=35
chrome.manifest
content akenispace jar:akenispace.jar!/chrome/content/
skin akenispace default jar:akenispace.jar!/chrome/skin/
locale akenispace en-US jar:akenispace.jar!/chrome/locale/en-US/
resource akenispace jar:akenispace.jar!/chrome/resource/
prefs.js
pref("toolkit.defaultChromeURI", "chrome://akenispace/content/space.xul");
Now you can put these files into your .wxs for WiX and produce an MSI file for Wndows.
Of course you need to include all the files for XULRunner as well.

Resources