« Oh, I’m green again
Playing with the new Pigment »

Flash Vorbis player

Yes, it’s been quite some time since I last posted. And yes, it’s been even longer since I promised something here, and still haven’t delivered. And no, there will be no excuses.

Instead, how about I share one thing with you…

The name is: FVorbis. Which stands for more or less “Ogg and Vorbis in Flash”. That’s right, pure ActionScript 3 implementation of the Ogg and Vorbis libraries that require no kind of native support from the Flash Player. A simple Vorbis player implemented using the new FVorbis lib compiles to about 46KB SWF file. And that’s it.

The source is actually written in haXe, not ActionScript, but the haXe compiler is able to produce proper AVM2 bytecode and put it into an SWF file that can be used with Flash Player all the same. Plus, using haXe has its numerous advantages.

The implementation relies on some new features that appeared in Flash Player version 10 (of which beta/RCs are available already for the most common platforms). That includes the new flash.Vector type and ability to generate sound programmatically.

For a very rough performance estimation: a ~50 seconds Vorbis file decodes completely in about 3-4 seconds at full speed of a single CPU core on my machine. In a player designed to decode at minimum speed allowing it to keep audio device playing continuous stream the CPU usage is at 5-15% of a single core. The machine is Core 2 Duo 2.6 GHz.

So, if you don’t have Flash 10 installed yet - go grab the latest version, and head to the first FVorbis demo at:

people.xiph.org/~arek/pg/hx/test.html

The source code’s public bazaar branch is currently at:

bazaar.launchpad.net/~arkadini/fogg/trunk/files

The haXe/Flash implementation of the Ogg and Vorbis libraries has been initially auto-translated from the Cortado’s JOrbis code, followed by several-thousand-lines patch transformation and manual type and system library call changes and adjustments. Followed by further fixing of imperfections of the automated translation and tedious hunting of a bug in haXe compiler. The patches for haXe compiler - adding support of the flash.Vector, SampleDataEvent, and forced tagging of generated swf files with version 10 - are included in the fogg.dev branch. In case you would like to play with the libraries yourself…

At this point great many thanks need to go to the whole Xiph.Org team for Vorbis and more, to the Fluendo group for Cortado and a hacking environment, to the author of the JOrbis for java implementation and to Tor-Einar Jarnbjo for inspiration.

Update: the project is now hosted on Launchpad.

This entry was posted on Friday, October 3rd, 2008 at 4:23 and is filed under Development, Xiph. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

66 comments on “Flash Vorbis player”

  1. Silvia Pfeiffer wrote:

    Totally rocking awesome! Can’t wait to see Theora in it, too. spacer

    October 3rd, 2008 at 5:12 #
  2. thomas.apestaart.org » Vorbis in Flash:

    […] I was wondering why Arek was arriving later than usual to work, to the point of being late at his own developer meeting where just a week before he instituted a rule that the last person in the meeting is to buy the rest of the team beer on Friday. This week he told me why, and yesterday he blogged about it: an implementation of the Vorbis decoder that works in Flash Player (albeit the newer version 10). It’s based on the Jorbis code which we took for Cortado, and it looks like it’s more than fast enough too. […]

    October 3rd, 2008 at 7:50 #
  3. phil wrote:

    Dude. You rock, you are a hero!

    October 3rd, 2008 at 7:55 #
  4. pancake wrote:

    Congratz for the release!

    Keep up the good job!

    October 3rd, 2008 at 10:19 #
  5. Gavin wrote:

    excellent. well done.

    October 3rd, 2008 at 11:39 #
  6. Flash的ogg和Vorbis格式播放器:

    […] 项目地址:barelyfocused.net/blog/2008/10/03/flash-vorbis-player/ […]

    October 3rd, 2008 at 14:16 #
  7. Markus wrote:

    Wow, excellent!

    October 3rd, 2008 at 16:08 #
  8. Kevin wrote:

    This is way cool. Thanks for this work.

    October 3rd, 2008 at 18:23 #
  9. brion wrote:

    Mwahahahha how deliciously evil >:D

    October 3rd, 2008 at 18:26 #
  10. oli wrote:

    how did you do the autotranslation?

    October 3rd, 2008 at 19:16 #
  11. James Ward wrote:

    This is very cool. For bonus points do this with a type 4 Pixel Bender filter so that it runs in a separate thread. spacer

    -James

    October 3rd, 2008 at 23:34 #
  12. Roy wrote:

    I think you should use JCraft’s JOrbis library, which is newer than Fluendo’s.
    www.jcraft.com/jorbis/index.html

    October 4th, 2008 at 4:51 #
  13. AS3 FVorbis Flash Ogg Vorbis Player « [ draw.logic ]:

    […] AS3 FVorbis Flash Ogg Vorbis Player October 4, 2008 — drawk This project is stacked with cool, but is also useful, an ogg/vorbis player in flash/as3.  Arek Korbik at barelyfocused.  Check out the demo (need flash player 10). Groovy. The name is: FVorbis. Which stands for more or less “Ogg and Vorbis in Flash”. That’s right, pure ActionScript 3 implementation of the Ogg and Vorbis libraries that require no kind of native support from the Flash Player. A simple Vorbis player implemented using the new FVorbis lib compiles to about 46KB SWF file. And that’s it. […]

    October 4th, 2008 at 8:42 #
  14. Arek wrote:

    @oli: I hacked the java2python project into a java2haxe one; it’s still missing some things but is mostly useful; the plan is to clean it up a bit and make available too.

    @Roy: good point - I wanted to start with something that I was 100% sure works for playing Vorbis files in a browser - I’ll check what’s new in JOrbis and see about porting the updates.

    October 4th, 2008 at 12:12 #
  15. Lucas Gonze’ blog » pure AJAX audio formats now a reality:

    […] The best hack I’ve seen since Brad Neuberg did AMASS in 2005: Arek Korbik implements Vorbis in Flash, with no dedicated Vorbis support provided by Adobe as part of Flash. It’s a god-level piece of hacking. […]

    October 4th, 2008 at 20:32 #
  16. Fabricio Zuardi wrote:

    Awesome! You rock!

    October 4th, 2008 at 21:06 #
  17. Marek Majkowski wrote:

    Great idea. Congratulations!

    October 4th, 2008 at 21:23 #
  18. Craig wrote:

    Wow, this is downright impressive.

    Combined with the new HTML5 audio tag’s support for Vorbis, this Flash implementation can be implemented as a backwards compatibility provider for non-HTML 5 browsers on otherwise HTML 5 sites. Extremely cool.

    October 5th, 2008 at 3:52 #
  19. Synthmax wrote:

    Sounds really good.
    So where is the demo and the code?

    if I follows people.xiph.org/~arek/pg/hx/test.html i got an empty page?

    and if I follows this I ended up in an empty reposotory

    people.xiph.org/~arek/bzr/fogg.dev/

    Best Synthmax

    October 5th, 2008 at 9:06 #
  20. Roy wrote:

    @Synthmax:
    lists.xiph.org/pipermail/vorbis-dev/2008-October/019586.html

    October 9th, 2008 at 4:23 #
  21. JeroenW wrote:

    Very cool!

    Why the FP10 dependencies? Do they improve performance? It’d be cool if this works in FP9, although I understand this might result into a performance drop.

    October 9th, 2008 at 22:03 #
  22. 纯Flash的ogg, Vorbis, MIDI, mod格式播放器 - Mac.6.cn:

    […] Web  6.cn   搜索 RSS 最新无回复主题 最强主题排行 会员登录历史 注册会员总数 2397讨论 28558收藏 4278据点 1408印迹 7381空间 285 Hosted by 6.cn Mac.6.cn > Internet > 分享发现 > 纯Flash的ogg, Vorbis, MIDI, mod格式播放器est地球1.021%disconnected登录后回复主题 | 跳到回复纯Flash的ogg, Vorbis, MIDI, mod格式播放器 … by est … 12 小时 41 分钟前 … 41 次点击 ogg+vorbis barelyfocused.net/blog/2008/10/03/flash-vorbis-player/ midi www.tan66.cn/new-midas3-sample-for-flashplayer10/ 国人做的 .mod格式播放器 gimme.badsectoracula.com/flashmodplayer/modplayer.html HaXe写的 via 1,2 本本用户乱入。有没有试成功ChiralMotion技术的? 创建新主题 … 目前这个主题还没有回复,或许你可以帮楼主加盖一层? 在回复之前你需要先进行登录电子邮件或昵称密码回到顶部 | 分享发现 | 返回 Mac.6.cn 首页 | 注册 | 找回密码 © 2007 6.cn  -  京ICP证060797号  -  About  -  V0.7-DEV Illusion Island var woopra_id = ‘789604568′; […]

    October 13th, 2008 at 21:01 #
  23. Ajaxian » Open Web Podcast - Episode 5: Ryan Stewart of Adobe:

    […] Video: A huge Flash advantage. Where does the video tag fit in? John pointed us to the experimental vorbis support via haXe […]

    October 14th, 2008 at 14:49 #
  24. Open Web Podcast - Episode 5: Ryan Stewart of Adobe:

    […] Video: A huge Flash advantage. Where does the video tag fit in? John pointed us to the experimental vorbis support via haXe […]

    October 14th, 2008 at 15:26 #
  25. Jonas wrote:

    Superb!

    Would it be possible to create an all AS3 version that would be possible to use in FP9?

    This would be really cool in combination with popforge library - loading ogg from the server, decoding them to wav samples for handling in popforge (code.google.com/p/popforge/)

    Regards / Jonas

    October 20th, 2008 at 10:33 #
  26. Alex McLean » Blog Archive » DSP in HaXe:

    […] However now Flash 10 is out and gives you full control, you can now pipe your samples out to audio.  Already cleverer people than me have done things like an ogg vorbis player, not using Adobe authoring tools but the excellent and properly free HaXe language which can compile to flash. […]

    November 12th, 2008 at 11:58 #
  27. 电器 wrote:

    文章好啊。我转载一下。是不是博主原产的啊。用不用注明出处.

    November 16th, 2008 at 1:03 #
  28. The WHATWG Blog » Blog Archive » This Week in HTML 5 - Episode 13:

    […] Everyone should go admire my new dog Beauregard, then scroll down to read “dave”’s non-Beau-related but extremely interesting comment on an experimental Ogg Theora video encoder. From there, I learned about this Ogg Vorbis audio decoder written in pure ActionScript (Flash), leading to the tantalizing but as-yet-unrealized possibility of a Javascript shim like mv_embed that could take <audio> elements that point to Ogg Vorbis audio files and replace them with a Flash wrapper that could play the audio file, even in browsers that do not support the <audio> element or the Ogg Vorbis audio codec. […]

    November 18th, 2008 at 22:58 #
  29. OGG Vorbis läuft nun in Flash 10 | Audio unter Linux:

    […] barelyfocused.net/blog/2008/10/03/flash-vorbis-player/ […]

    November 19th, 2008 at 19:19 #
  30. Richard wrote:

    You dev link goes to an empty directory

    November 19th, 2008 at 21:32 #
  31. Roy wrote:

    original vorbis library was ported to flash with adobe Alchemy.
    labs.adobe.com/wiki/index.php/Alchemy:Libraries

    November 20th, 2008 at 11:41 #
  32. Kevin Newman wrote:

    I can’t wait to see some performance comparison between the Adobe Alchemy port, and your HaXe port. spacer

    November 20th, 2008 at 17:13 #
  33. Billigflug wrote:

    Nice work ! I cant wait for it …I hope thouse prog is not your last!
    Keep it on my friend. Special thx and greets

    November 27th, 2008 at 15:18 #
  34. Hugo wrote:

    Nice work ! I cant wait for it too! Have you the source code of the flash movie called test.swf (people.xiph.org/~arek/pg/hx/test.html).

    Congratz for the release!

    November 27th, 2008 at 17:59 #
  35. Hanicken wrote:

    My friend, God Bless you! =)

    December 3rd, 2008 at 21:09 #
  36. Swirling » Blog Archive » RIAs and Free Software:

    […] How come there’s no Flash-based Ogg player? Actually, it seems that a Vorbis player is being worked on, which is great, but I’m still puzzled that this hasn’t come about way, way earlier. […]

    December 10th, 2008 at 11:58 #
  37. Victor wrote:

    Hi friend Haxer ! ^^

    Thanks a lot for developping and sharing this code! It is very useful going forward massive ogg sound support..

    I’m working on a sound archive website and try to make an universal sound player for it (mp3 and ogg), but I have a problem with 22050khz files playing too quick, do you have an idea how to solve this, or where to search in the sources ? Some of the functions and sound variables are quite obscure to me, but i’m digging !

    I tried to play the sounds with JOrbis and they play an normal speed..

    Have good time!

    Victor

    December 24th, 2008 at 16:56 #
  38. Don-Duong Quach wrote:

    Hey Victor,

    I’m also trying to solve a similar issues. I tried downloading a couple Youtube mp4’s and converting them in Audacity to 44khz ogg vorbis files. They’re reported by the player as 44khz, but they playback too fast. Other files converted from mp3’s sound fine.

    Hey Arek,

    Thanks for putting out this really useful library! I’ll post if I resolve these issues.

    Don Q.

    February 3rd, 2009 at 19:55 #
  39. Don-Duong Quach wrote:

    Hmm looks like my issue is related to tinkering with the PAudioSink threshold values which is forcing a data read too often. I was trying to get a high quality ogg file to play, but adjusting the values allowed the high quality file to play but hurts the playback of smaller files.

    I’ll look into adjusting the threshold value automatically based the size or number of samples in the file.

    -Don Q.

    February 4th, 2009 at 1:13 #
  40. file/new » Daily Digest for 2009-02-14:

    […] Barelyfocused » Flash Vorbis player This entry was written by Sascha and posted on February 14, 2009 at 11:59 pm and filed under Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL. […]

    February 15th, 2009 at 16:58 #
  41. Brasilien wrote:

    Thank you for this helpfull comment!!!

    February 24th, 2009 at 1:04 #
  42. Sergej wrote:

    Good work!!
    But there is a way to add simple control-button, to stop the music, and something like this?

    March 8th, 2009 at 20:08 #
  43. antxon wrote:

    I’ve the same question Sergej has, is there or will be any player with buttons and such?

    March 25th, 2009 at 17:24 #
  44. Arek wrote:

    @Victor: yes, the library at the moment lacks a resampler, and since Flash’s audio is fixed at 44.1 kHz any files with a different sample rate won’t play at correct speed.

    @Don-Duong: you might want to check the soundapi branch on the fogg launchpad project.

    @Sergej, @antxon: I won’t have time to make a UI myself, but my idea is to find eventually a popular, open-source flash audio player and integrate it with fogg (or other way around).

    March 26th, 2009 at 0:22 #
  45. LMC wrote:

    JOrbis can chain a stream (i.e. if say icecast is being fed by a client source, that sends it one ogg file, and then another there appears to be no break to the stream client of icecast - the JOrbis client), so continuous playout is maintained for chaining streams.

    Is there any chance fvorbis could be modified to do such a thing? The stream below is an example of a chaining stream:

    stream.karmasj.com/karma.ogg

    I’ve got version of the test.swf posted up on

    stream.karmasj.com/test.swf?playUrl=stream.karmasj.com/karma.ogg

    and as you can see it plays the very first ogg opener file, but then stops. The JOrbis code doesn’t do this (see karma.fm for an example).

    April 15th, 2009 at 6:11 #
  46. Ole wrote:

    Here are so much commercial comments. Why?

    April 15th, 2009 at 14:16 #
  47. David wrote:

    Any tip on an AS3 Vorbis Encoder ???

    April 22nd, 2009 at 5:07 #
  48. Gibbo wrote:

    Good work! Thanks you!
    I should like to play a little with your code, but I have same problem downloading the branch using bazaar (I m on a WinXp machine). The command I’m using is:
    bzr branch lp:fogg
    This command give me the error: unable to create symlink on this platform.
    I’ve tried to a little bit investigate, but I’m unable to solve the problem.
    Is there a way you can help me someway ? A good solution should be to have the last code downlodable from another place and in another way… but an email attachment shoul be really appreciate also. Thanks a lot.

    April 24th, 2009 at 16:13 #
  49. anon-e-moose wrote:

    Great library, many thanks!
    I have adapted the example code to make a very simple stream player for web radio, with all control functions (play/stop, volume) and tag display offloaded to javascript through ExternalInterface.
    This included changing the AudioSink a bit to allow for volume control, and stream changing during playback.
    @LMC: this will handle your problem, i believe
    I will post a link here the moment the new version will be finished.

    @Gibbo: same here, i couldn’t download the code, but managed to export it to zip, using bzr export. After that, it compiled and worked without a problem, but naturally, i can’t post my changes back to launchpad.

    The only problem so far is inability to play at quality rates higher than ~128 kbps. The stream loads, but does not play.

    April 27th, 2009 at 18:09 #
  50. anon-e-moose wrote:

    As promised.
    code.google.com/p/anoggplayer/

    April 29th, 2009 at 15:30 #
  51. LMC wrote:

    Thanks anon! DL’ing now and will give it a try when I get home

    May 4th, 2009 at 23:01 #
  52. Buck wrote:

    I’ve just managed to add the Alchemy SWC into my radio application, Antenna. More info here: bcdef.org/2009/05/13/ogg-in-flash-yes-you-can-now-how-about-wma/

    May 14th, 2009 at 21:08 #
  53. Bruno Sant'Anna wrote:

    Hello there, does this implementation works with OGG Speex implementation? (www.speex.org/)

    May 15th, 2009 at 14:11 #
  54. anon-e-moose wrote:

    Finally found how to fix the quality issue: the player can now play both low and high quality streams/ogg files. All the issue was the demux buffer being too small.
    It was set to 8192 bytes, while it should be 16384 to play the higher-quality files.

    May 23rd, 2009 at 21:12 #
  55. mixblendr wrote:

    wow this is really cool! I’ve been looking for a better player than cortado for my open source remixing software project,

    Has anyone developed a UI for the player yet?

    May 28th, 2009 at 6:27 #
  56. John Drinkwater wrote:

    Hi,
    Did you ever get the time to clean up or post java2haxe?
    Very interested developer looking at FTheora…

    July 2nd, 2009 at 13:39 #
  57. unFocus Projects » unFocus.Games – Tetris clone:

    […] I made a promise on someone else’s blog to post the code for the Tetris clone I made a while back, probably in fatigue induced delirium, a little bit ago, so here it is in a new Google Code project called unFocus.Games. The post on bit-101 post was about game architecture. While developing the code for the clone, I did play with concepts around architecture quite a bit. I also played with learning about Flash 10 features – adding PixelBender filters, and even having an Ogg Vorbis based soundtrack for a while (tried both the HaXe decoder, and the Alchemy decoder). I took them both out for now though, as well as some of the more unorthodox uses of Actionscript 3.0 I had in there – I was experimenting, and besides, Flash CS4’s compiler is a bit more finicky than Flash CS3’s was. One of these days I’ll get around to blogging about some of that stuff. […]

    July 10th, 2009 at 0:13 #
  58. cjcshadow wrote:

    Spider-Man

    August 20th, 2009 at 1:59 #
  59. OpenLaszlo, HTML 5 and CSS3 – driving adoption of open standards in RIAs:

    […] The battle for open standards based web video continues. While it seemed that there could be a general agreement on codecs earlier this year, a few weeks ago it showed that it will be as difficult as expected to win support for one codec by makers of Firefox, Safari and Opera – not to talk about Microsoft and IE here. Technically it’s easy to include open standards based video into  OpenLaszlo DHTML applications, and the haXe team has proven that you can support codecs like Ogg and Vorbis in Flash as well. […]

    August 21st, 2009 at 16:12 #
  60. Sumit wrote:

    Could you help me in ogg decoder-
    Basically I just want to initialize the decoder and wait for the packets for sometime.
    Current implementation limits the demuxer data size to 8192 and cant be small as 4096. Could you help in this regard? or Atleast guide me the path?

    August 23rd, 2009 at 17:29 #
  61. BlackOut wrote:

    thx for this articles spacer

    September 5th, 2009 at 16:52 #
  62. freestylo wrote:

    Hi, I found lots of good information in your blog. thank you

    September 24th, 2009 at 20:57 #
  63. anon-e-moose wrote:

    Oh, it seems this post still lives. I will push a major update for anOggPlayer in a few days. In this update: progress bar, pause/continue function, and i’m trying to add random seeking ability. Also in this release a basic UI example in 100% javascript. This is, i think, the best way to integrate a player, without having to embed a visible flash window that might not match the visual style of the page.

    October 13th, 2009 at 17:31 #
  64. stef wrote:

    Sorry but I don’t really get it. Isn’t that possible to have a swc for that? Or at least a simpler way to use it? Also, isn’t that possible to have a simple zip file to download the source code? Sorry I’m not an hardcore developer, so I don’t really like spending lots of time just to download a folder or use a lib…

    November 6th, 2009 at 21:20 #
  65. Weekly Digest for November 13th — Hello. My name is Václav Vančura.:

    […] Barelyfocused » Flash Vorbis player […]

    November 13th, 2009 at 18:32 #
  66. iHandler – AIR iTunes Exporter | n8o:

    […] This is a cool little tool written in AIR by Ondrej Rafaj. What iHandler does, is allows you to export your selected files from your iTunes library. I could really see a project like this doing some cool new stuff in the future with the new AIR 2.0 api’s. Maybe let you play your music through the web using an HTTP AIR Server or export them to different formats using the AS3 OGG Vorbis library. Just a thought. […]

    December 8th, 2009 at 16:23 #

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.