| Subcribe via RSS

Flash plays certain MP3s back at double speed – why?

July 27th, 2008 | No Comments | Posted in Actionscript 2.0

A colleague and I recently found some odd things happening with dynamically loaded audio in an elearning application we have been working on. The external MP3s seemed to be playing back at double speed, and as a result the audio was a hideously high-pitched mess. The weird thing was, this wasn’t happening on every machine. Some computers, including mine, would play the audio back fine but a couple of other people were reporting the same problem so we had to look into it. Bah.

After much fiddling, we reached the following conclusions:

  • Flash seems unable to handle MP3s encoded with a variable bit rate (VBR)
  • Flash seems unable to reliably handle MP3s which have a sample rate which is not 44,100 Hz, 22,050 Hz or 11,025 Hz.
  • Additionally, it seems possible that there are certain bit rates which are also not handled well by Flash. We’ve tested files successfully at 40kbps, 80kps, 120kbps (and many other multiples of 40).

(Note: This was happening in an application built with Actionscript 2.0 for Flash Player 8. I haven’t had a chance as yet to see if the same problem occurs in SWFs running in AVM2)

While the problem of the audio playing at double speed did seem fairly hard to recreate, we did find another way of highlighting the problem. The JW Media Player is a popular, open-source MP3/FLV Player and can see be seen in-use all over the internet. From our tests, ‘incorrectly’ encoded MP3 files can also create a problem when played as part of a playlist in the JW Media Player. If the user is listening to one of these MP3s, and moves the seek bar somewhere between half-way and the end of the file, the Media Player incorrectly decides that the MP3 has finished, and automatically moves to the next item in the playlist. Without looking into the code in more detail, this kind of assumes that the information Flash is broadcasting about the MP3 (for example sample length, or current position.) is incorrect, which is causes the MP3 to finish prematurely. Re-encoding the audio to match the criteria listed above will always fix this problem.

(Note: Current versions of the free Audio editing software Audacity, used in tandem with the LAME MP3 encoder, do not allow you to choose the bitrate of the exported MP3. However, the Beta version of Audacity 1.3 does offer that functionality via the Options button in the Export Dialog. The Beta version of this software can currently be downloaded from http://audacity.sourceforge.net/download/.)

Tags: , , ,

XML-RPC in Actionscript 3.0 – couple of gotchas

July 25th, 2008 | 2 Comments | Posted in Actionscript 3.0

As part a recent project, I’ve needed to integrate a Flex 3 application with an existing XML-RPC webservice. Over the years I’ve not done a huge amount of webservice integration with Flash. In the past I would typically choose to send data back and forth from the server using the built in XML or LoadVars objects available in Actionscript 2.0. On a couple of projects, I ended up using the Flash Remoting API and AMFPHP to achieve what I wanted and everything turned out pretty well, and once I integrated an application with some .NET SOAP webservices. But XML-RPC was a new one on me.

Anyway, after a bit of research, I was a little surprised to discover that XML-RPC hasn’t already been supported by the Flex framework, but after looking around I came across as3-rpclib, an open-source library that not only supports XML-RPC, but also AMF0 and JSON-RPC (I’ve currently only used these classes with XML-RPC, so can’t comment on the other formats implements).

So far, the classes have worked really well for me. However I did hit a couple of stumbling blocks along the way which I’ll attempt to detail here.

Continue reading XML-RPC in Actionscript 3.0 – couple of gotchas »

Tags: , , , ,

PureMVC – Multicore vs Standard / Singlecore

July 23rd, 2008 | 2 Comments | Posted in PureMVC

I’ve recently started using the Actionscript 3.0 Multicore implementation of PureMVC in order to use the framework within a modular Flex application. At the time of writing, most of the PureMVC examples and tutorials online are relevant to the Standard, or Singlecore,  version of the framework.

In general, the methodology and syntax is indentical across both versions of the framework. There are, however, a couple of minor differences which are pretty important, as without understanding these little quirks, many of the sample applications built using the Singlecore implementation will break when ported to Multicore.

The Standard version of PureMVC uses Singletons to provide access to the framework’s core actors. Within the framework, access to the Facade, Model, View and Controller are all provided using a standard getInstance method. To allow multiple instances of the framework to co-exist, the Multicore version of the framework uses Multitons, and then access to the various actors is provided within the framework by passing a unique instance key to the getInstance methods. The idea is simple – each separate instance of the framework has its own unique key, and so multiple instances of the actors may co-exist without interfering with each other.

Continue reading PureMVC – Multicore vs Standard / Singlecore »

Tags: , ,

Discovering PureMVC, and scaling the learning curve

July 21st, 2008 | No Comments | Posted in PureMVC

Background
A while back I began work on a personal project which would involve me finally getting to grips with Flex, Django and XML-RPC. I’ve been using Actionscript 3.0 for quite a while, but my experience with Flex had been relatively minimal. After getting past the initial “What the hell actually is Flex?” thing I spent some time trying to learn the basics.

I started off by going through the Flex Builder tutorials, built the sample application featured in Flex 3 – Training from the Source , signed up for the Flexcoders mailing list and even built a couple of little apps to help me automate some fairly dull database maintenance I’d been putting off. But at that point I’d never done any real work with Flex, and it quickly became obvious that I wasn’t sure where to begin when it came to structuring a fairly large application.

I’d read a bit about the various frameworks available for Flash and Flex, but I’d always kind of written them off as not applicable for me. I had my own way of doing things which, up until now, had always worked well for me and I saw no reason to change. This time, things were a little different,  and I decided that it might be time to revisit them.

Continue reading Discovering PureMVC, and scaling the learning curve »

Tags: , ,