ASaudio&SoundAS 两个开源项目阅读:

ASaudio&SoundAS 都是比较小巧的声音控制,但似乎都不能直接拿到项目只直接使用。

ASaudio

ASaudio的Track,Group和Tween的TweenCore SimpleTimeline有些类似,但相对简单点。

它的音量控制是也是通过enterFrame+getTimer实现的。

但项目中已经有了通过的enterFrame,如果直接使用的话,会有些浪费,需要嵌入到项目中才比较好。

另外ASaudio也是在enterFrame中监听audio是否播放完成,进而抛出事件的。这个避免了原生的sound在播放完成时可能存在的bug。

这个bug是 在播放完一段声音时soundchannel.position 和 sound.length的值有差距。测试结果:soundchannel.position< sound.length

SoundAS

SoundAS相对来说更实用一点。它引用了Signal类库,如果在项目中采用的话,要么也同时引起该类库,要么再做修改。工作量一样很大。

对于同一个url,SoundAS做了缓存处理,不会new一个sound,这点比ASaudio好。

SoundAS的代码注释中还提供的一个channel bug,url地址:http://www.stevensacks.net/2008/08/07/as3-sound-channel-bug/

这个bug时,如果循环播放一段声音,通过channel.position得到的位置可能是超出声音长度,当你使用这个位置数据调用play方法时就会报错。

原文如下:

I don't know if this has been documented or not.

If you set a Sound to loop, it's channel.position property returns a number out of range of the Sound.length after it loops. The position property just keeps on incrementing beyond the length when you loop a sound.

If you try to play a Sound from that out of range position, the Sound glitches out, because that position is invalid, even though Flash returns it to you, implying it's valid. Flash should not return an invalid position to you.

This all revolves around the fact that Sound has absolutely no way to pause right now. I don't know why Adobe did not give us a channel.pause() method. Because they chose not to, this bug has bad consequences.

The only way to pause and unpause a sound in Flash is to store the current position of the channel and call channel.stop(), and when you unpause, you call sound.play(position). This works fine if you're only playing the sound once. If you're looping, however, it doesn't at all.

If the sound is looping, the position returned will eventually be higher than the length, which means the Sound glitches because you're passing an out of range position; a position, once again, that Flash returned to you as valid.

Wait, it gets worse. If you unpause a looping sound by passing its position, when it loops, it will loop from that position, not the beginning of the Sound. Problem!

There is no pause method for channel, and without a pause method, there is no workaround for the above bug and issue except to manually loop a Sound by adding an event listener to the sound complete event (which can be unreliable), calling play on it again and managing the looping manually, which undermines the loops argument of the Sound.play() method and requires a fair amount of code.

Adobe, we need a channel.pause(flag:Boolean) method.

sound tips的更多相关文章

  1. android 官方文档 JNI TIPS

    文章地址  http://developer.android.com/training/articles/perf-jni.html JNI Tips JNI is the Java Native I ...

  2. English Phrases with THE – Linking the TH Sound

    English Phrases with THE – Linking the TH Sound Share Tweet Share Tagged With: The Word THE Study En ...

  3. Learn English like a Baby – How to Sound Native

    Learn English like a Baby – How to Sound Native Share Tweet Share Tagged With: tips & tricks Wha ...

  4. Productivity tips, tricks and hacks for academics (2015 edition)

    Productivity tips, tricks and hacks for academics (2015 edition) Contents Jump to: My philosophy: Op ...

  5. (Forward)5 Public Speaking Tips That'll Prepare You for Any Interview

    Landing a job interview is incredibly exciting –- and often terrifying. But fear not. There are clev ...

  6. 10 Essential TypeScript Tips And Tricks For Angular Devs

    原文: https://www.sitepoint.com/10-essential-typescript-tips-tricks-angular/ ------------------------- ...

  7. Android 性能优化(18)JNI优化:JNI Tips 提升性能技巧

    JNI Tips 1.In this document JavaVM and JNIEnv Threads jclass, jmethodID, and jfieldID Local and Glob ...

  8. Direction of Arrival Based Spatial Covariance Model for Blind Sound Source Separation

    基于信号协方差模型DOA的盲声源分离[1]. 在此基础上,作者团队于2018年又发布了一篇文章,采用分级和时间差的空间协方差模型及非负矩阵分解的多通道盲声源分离[2]. 摘要 本文通过对短时傅立叶变换 ...

  9. Mac上MySQL忘记root密码且没有权限的处理办法&workbench的一些tips (转)

    忘记Root密码肿么办 Mac上安装MySQL就不多说了,去mysql的官网上下载最新的mysql包以及workbench,先安装哪个影响都不大.如果你是第一次安装,在mysql安装完成之后,会弹出来 ...

随机推荐

  1. flume-ng+Kafka+Storm+HDFS 实时系统搭建

    转自:http://www.tuicool.com/articles/mMrQnu7 一 直以来都想接触Storm实时计算这块的东西,最近在群里看到上海一哥们罗宝写的Flume+Kafka+Storm ...

  2. 未能加载文件或程序集"Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad

    问题: 未能加载文件或程序集"Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3 ...

  3. 李洪强iOS开发之多线程编程2-NSOperation

    前言 1.上一讲简单介绍了NSThread的使用,虽然也可以实现多线程编程,但是需要我们去管理线程的生命周期,还要考虑线程同步.加锁问题,造成一些性能上的开销.我们也可以配合使用NSOperation ...

  4. DIV CSS设计时IE6、IE7、FF 与兼容性有关的特性(转载的)

    在网站设计的时候,应该注意css样式兼容不同浏览器问题,特别是对完全使用DIV CSS设计的网,就应该更注意IE6 IE7 FF对CSS样式的兼容,不然,你的网乱可能出去不想出现的效果! 所有浏览器 ...

  5. Jlink更新新固件USB连接不上的问题

    采购新买了一个jlink,在调试过程中发现不能使用.拿到手后对jink上电以后,发现灯不亮,到网上查了一下估计是固件损坏的原因,经过一番摸索从新更新了固件,然后可以正常使用了,下面说一下步骤: 新版的 ...

  6. MyBatis笔记——初次环境配置

    简单介绍 MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBati ...

  7. MFC中Edit Control值的获取与赋值

    void CEditControlDlg::OnClickedButton() { // TODO: Add your control notification handler code here / ...

  8. 【原创】如何在Android中为TextView动态设置drawableLeft等

    如何在Android中为TextView动态设置drawableLeft等   两种方式:   方式1:手动设置固有边界 Drawable drawable = getResources().getD ...

  9. POJ3176——Cow Bowling(动态规划)

    Cow Bowling DescriptionThe cows don't use actual bowling balls when they go bowling. They each take ...

  10. Lucene学习笔记(更新)

    1.Lucene学习笔记 http://www.cnblogs.com/hanganglin/articles/3453415.html