sound tips
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的更多相关文章
- android 官方文档 JNI TIPS
文章地址 http://developer.android.com/training/articles/perf-jni.html JNI Tips JNI is the Java Native I ...
- 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 ...
- 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 ...
- Productivity tips, tricks and hacks for academics (2015 edition)
Productivity tips, tricks and hacks for academics (2015 edition) Contents Jump to: My philosophy: Op ...
- (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 ...
- 10 Essential TypeScript Tips And Tricks For Angular Devs
原文: https://www.sitepoint.com/10-essential-typescript-tips-tricks-angular/ ------------------------- ...
- Android 性能优化(18)JNI优化:JNI Tips 提升性能技巧
JNI Tips 1.In this document JavaVM and JNIEnv Threads jclass, jmethodID, and jfieldID Local and Glob ...
- Direction of Arrival Based Spatial Covariance Model for Blind Sound Source Separation
基于信号协方差模型DOA的盲声源分离[1]. 在此基础上,作者团队于2018年又发布了一篇文章,采用分级和时间差的空间协方差模型及非负矩阵分解的多通道盲声源分离[2]. 摘要 本文通过对短时傅立叶变换 ...
- Mac上MySQL忘记root密码且没有权限的处理办法&workbench的一些tips (转)
忘记Root密码肿么办 Mac上安装MySQL就不多说了,去mysql的官网上下载最新的mysql包以及workbench,先安装哪个影响都不大.如果你是第一次安装,在mysql安装完成之后,会弹出来 ...
随机推荐
- 在Vista或Windows 7系统上安装Sharepoint 2007
在Vista或Windows 7系统上安装Sharepoint 2007 2010-03-05 18:53:19| 分类: 技术文章|字号 订阅 SharePoint 2007 不能直接安装 ...
- 饶有兴致的用javascript做了个贪食蛇游戏
09年写的东西.一直藏在自己的记事本里头,现在开始整理写博客,所以直接搬过来 先上效果图 再添代码: <HTML> <HEAD> <TITLE>贪吃蛇 Snake ...
- 从.NET 1.1 升级到.NET 4.0 遇到 线程间操作无效: 从不是创建控件 [XX] 的线程访问它.
有两种方式解决 1.在窗体构造函数中写Control.CheckForIllegalCrossThreadCalls =false;2.使用Invoke等委托函数 问题原因是 .NET2.0 以后拒绝 ...
- lintcode : 跳跃游戏
跳跃游戏 给出一个非负整数数组,你最初定位在数组的第一个位置. 数组中的每个元素代表你在那个位置可以跳跃的最大长度. 判断你是否能到达数组的最后一个位置. 样例 A = [2,3,1,1,4],返回 ...
- [C#] 區分 abstract、virtual、override 和 new
abstract.virtual.override和new是在類別的繼承關係中常用的四個修飾方法的關鍵字,在此略作總結. 1. 常用的中文名稱: n abstract => 抽象方法. n ...
- servlet中中文乱码问题
在web项目中经常回碰到中文乱码的问题,特此整理一下,有不足的地方,希望大家纠正. 1从前台往后台传数据,.以get方式发送请求,发送的参数不乱,但是后台接收到参数乱码 在Tomcat的server. ...
- Java-J2SE学习笔记-查找一个String中,subString的出现次数
1.查找一个String中,subString的出现次数 2.代码 package Test; public class TestStringContain { public static void ...
- iphone 6 设置自定义铃声(未越狱)
环境: ipone 6 iTunes 12.4.0.119 IOS 9.3.2 先把需要设置的铃声下载到电脑上,然后打开iTunes下的文件->将文件添加到资料库,如图: 2.在音乐列表里右击所 ...
- SPOJ 227 Ordering the Soldiers 线段树 / 树状数组
题意:设原数组为a[i],pos[i]代表第 i 个位置之前有多少个数比a[i]大,求原数组a[i]. 这个题意是看了别人的题解才明白,我自己没读出来…… 方法:假设我们从左往右放,因为后面的数还有可 ...
- 数组工具类 - ArrayUtil.java
数组工具类,提供数组.对象之间转换的方法. 源码如下:(点击下载 - ArrayUtil.java .commons-lang-2.6.jar) import java.lang.reflect.Ar ...