如何从缓冲区(的ByteArray /流)在ActionScript 3播放MP3的声音?缓冲区、声音、ActionScript、ByteArray

由网友(羙ㄝホ寸ㄝ婿)分享简介:所以..我有一个缓冲带MP3数据(如果我保存这个缓冲区,并调用它buffer.mp3会上场,但在这种情况下,我不应该将其保存到文件系统) 。 我要玩的话,但我做不到,我该怎么办? 我试了下code到播放buffrer(ByteArray的\流)(我从服务器获取数据的方法工作正常的MP3数据(上测试文本廉政局等),我称之...

所以..我有一个缓冲带MP3数据(如果我保存这个缓冲区,并调用它buffer.mp3会上场,但在这种情况下,我不应该将其保存到文件系统) 。 我要玩的话,但我做不到,我该怎么办?

我试了下code到播放buffrer(ByteArray的流)(我从服务器获取数据的方法工作正常的MP3数据(上测试文本廉政局等),我称之为返回的ByteArray readResponse因为我有一些seading方法,这是它的响应)。

 受保护的功能播放(事件:MouseEvent)方法:无效
{
VAR为mySound:声音=新的声音();
mySound.addEventListener(的SampleDataEvent.SAMPLE_DATA,soundFill);
mySound.play();
}

公共职能soundFill(事件:的SampleDataEvent):无效
{
event.data.writeBytes(readResponse.buffer,0,readResponse.buffer.length);
}
 

解决方案

本之一,因为SampleDataEvent.data不起作用预计uncom pressed原始样本数据,而不是MP3。使用 http://wiki.github.com/claus/as3swf/玩-MP3-直接从 - ByteArray的代替。

C语言 高速缓存与缓冲区

So.. I have a buffer with MP3 data (If I would save this buffer and call it buffer.mp3 it would play, but in this situation I should not save it to file system). I have to play it, but I can not, what shall I do?

I tried the next code to play that buffrer(ByteArrayStream) (I get MP3 data from server the method of getting data works fine (tested on text int's etc) I call the returned ByteArray readResponse because I have some seading method and It is it's response).

    		protected function Play(event:MouseEvent):void
		{
			var mySound:Sound = new Sound();
			mySound.addEventListener(SampleDataEvent.SAMPLE_DATA, soundFill);
			mySound.play();	
		}

		public function soundFill(event:SampleDataEvent):void
		{
			event.data.writeBytes(readResponse.buffer, 0, readResponse.buffer.length);	
		}

解决方案

This one doesn't work since SampleDataEvent.data expects uncompressed raw sample data, not MP3. Use http://wiki.github.com/claus/as3swf/play-mp3-directly-from-bytearray instead.

阅读全文

相关推荐

最新文章