如何将声音放入Android动画中?(How to put sound in an android animation? [closed])
我需要用声音制作动画。 当ImageView旋转时,IE会发出类似于tic tic tic的声音,直到它结束
I need to make an animation with sound. IE when an ImageView is rotating it makes a sound like tic tic tic until it ends
原文:https://stackoverflow.com/questions/22004729
更新时间:2020-02-11 10:49
最满意答案
对于像嘀嗒声或嘀嗒声这样的小声音,请使用SoundPool。 使用soundpool更有效率,而不是复杂而沉重的MediaPlayer!
这是一个关于SoundPool的体面教程。
还可以使用AnimationListeners同步动画和音频。
For little sounds like a tick or tock, use SoundPool. It's much more efficient to use soundpool, rather than a complicated and heavy MediaPlayer!
Here's a decent tutorial on SoundPool.
Also use AnimationListeners to synchronize your animation and audio.
2014-02-25
相关问答
在MediaPLayer中声明MediaPLayer的MyWebViewClient ,添加以下内容... public class MyWebViewClient extends WebViewClient{
public MediaPlayer mp;
private Context context = null; // Add this line
...
}
然后按如下方式向MyWebViewClient添加一个构造函数... public MyWebViewC
...
简单地将下面的代码放在块中,当发生通知时将触发该代码。 mMediaPlayer = new MediaPlayer();
mMediaPlayer = MediaPlayer.create(this, R.raw.mySound);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setLooping(true); // Set false if you don't want it to loop
...
您可以播放音频移动到服务。 你可以参考ASOP音乐代码或外观 绑定到已启动的服务 如“服务”文档中所述,您可以创建既启动又绑定的服务。 也就是说,可以通过调用startService()来启动服务,该服务允许服务无限期地运行,并且还允许客户端通过调用bindService()来绑定到服务。 如果您确实允许启动和绑定服务,那么当服务启动时,系统不会在所有客户端解除绑定时销毁服务。 相反,您必须通过调用stopSelf()或stopService()来显式停止服务。 you can playback
...
对于像嘀嗒声或嘀嗒声这样的小声音,请使用SoundPool。 使用soundpool更有效率,而不是复杂而沉重的MediaPlayer! 这是一个关于SoundPool的体面教程。 还可以使用AnimationListeners同步动画和音频。 For little sounds like a tick or tock, use SoundPool. It's much more efficient to use soundpool, rather than a complicated and h
...
我不建议将游戏作为Android初学者编写,因为编写游戏时,根据您使用的游戏类型,样式和工具可能会非常棘手。 在最基本的层面,如果你在屏幕上移动一个位图,android会附带一个用于翻译的API,它会改变一个对象的位置。 看看这里: http://developer.android.com/reference/android/view/animation/Animation.html 如果您的图像是图像视图,请记住一件事,然后将其视为视图,并且可以对其应用动画。 您可以使用的其他参考: http:
...
您是否尝试将声音组件放在模型上,或者作为它的孩子?
Did you try putting the sound component on the model, or as a child of it?
...
我需要将Audacity中的原始声音片段保存为11025 HZ 16位OGG文件。 这允许剪辑尽可能长。 I needed to save my original sound clips in Audacity as 11025 HZ 16-bit OGG files. This allows the clips to be as long as I want.
乍一看,虽然我没有仔细检查你的代码或者亲自尝试过你的代码,但是我可以看到你用ObjectOutputStream.writeObject()编写数组,但是把它读作原始字节。 这肯定会引起问题。 ObjectOutputStream.writeObject()用于序列化Java对象; 它写的不仅仅是原始数据,即使对于数组也是如此。 它编写了对象类,签名和其他一些东西,以便它可以通过另一端的ObjectInputStream进行反序列化(如果你很好奇,可以在这里指定这种格式)。 你有很多选择。 我能想
...
对于这样的效果(在Koi Pond中使用),您将需要几个像素着色器。 要使用它,您需要使用OpenGL ES 2.0。 我建议使用像AndEngine这样的游戏引擎进行基本设置和着色器使用。 如果您没有使用着色器的经验,那就不那么容易了! 我不确定AndEngine是否是最好的选择,但它有可能。 看看http://www.andengine.org/ 论坛中还有一些着色器教程 For such effects (as used in Koi Pond) you will need several
...
尝试阅读以下文档: http://developer.android.com/reference/android/media/SoundPool.html 这可以处理操作系统上的播放声音。 Try reading the documentation of: http://developer.android.com/reference/android/media/SoundPool.html This handles playing sounds on the OS.