使用html5中的base64数据播放音频

时间:2012-10-18 09:31:00

标签: android base64 android-mediaplayer html5-audio

我创建了一个使用原生mediaPlayer录制音频的应用程序,将此音频文件转换为base64数据,并将其传递给html5音频标签,如下所示,

File file = new File(Environment.getExternalStorageDirectory()+"/"+ "audiofile"+"/"+"myAudio.mp3");
byte[] FileBytes =getBytesFromFile(file);
String base64 = Base64.encodeToString(FileBytes, Base64.NO_WRAP).toString();


public static byte[] getBytesFromFile(java.io.File file) throws IOException 
{
        InputStream is = new FileInputStream(file);
        long length = file.length();
        if (length > Integer.MAX_VALUE)
                         {

        }
        byte[] bytes = new byte[(int)length];
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length
               && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
            offset += numRead;
        }
        if (offset < bytes.length) {
            throw new IOException("Could not completely read file "+file.getName());
        }
        is.close();
        return bytes;
}

将此base64值传递给网页(此处为base64数据示例),

<div id="audiodiv" >
<audio id="audio_player" src="data:audio/mp3;base64,AAAAGGZ0eXAzZ3A0AAAAAGlzb20zZ3A0AAARTG1kYXQEYzzH8GMEOf/gAAAABDcYx/BtBDP/4AAAAAQ2PMfwZwQ1/+AAAAAE/xjH8G0EM//gAAAABDY8x/BnBDX/4AAAAAT/GMfwbQQz/+AAAAAENjzH8GcENf/gAAAABP8Yx/BtBDP/4AAAAAQ2PMfwZwQ1/+AAAAAE/xjH8G0EM//gAAAABDY8x/BnBDX/4AAAAAT/GMfwbQQz/+AAAAAENjzH8GcENf/gAAAABP8Yx/BtBDP/4AAAAAQ2PMfwZwQ1/+AAAAAE/xjH8G0EM//gAAAABDY8x/BnBDX/4AAAAAT/GMfwbQQz/+AAAAAENjzH8GcENf/gAAAABP8Yx/BtBDP/4AAAAAQ2PMfwZwQ1/+AAAAAE/xjH8G0EM//gAAAABDY8x/BnBDX/4AAAAAT/GMfwbQQz/+AAAAAENjzH8GcENf/gAAAABP8Yx/BtBDP/4AAAAAQ2PMfwZwQ1/+AAAAAE/xj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xQ7g6AAACMW1vb3YAAABsbXZoZAAAAABQf8UMUH/FDAAAA+gAABqQAAEAAAEAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAGldHJhawAAAFx0a2hkAAAAB1B/xQxQf8UMAAAAAQAAAAAAABqQAAAAAAAAAAAAAAAAAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAABQW1kaWEAAAAgbWRoZAAAAABQf8UMUH/FDAAAH0AAANSAAAAAAAAAACxoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGUAAAAA7W1pbmYAAAAQc21oZAAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAAsXN0YmwAAABFc3RzZAAAAAAAAAABAAAANXNhbXIAAAAAAAAAAQAAAAAAAAAAAAEAEAAAAAAfQAAAAAAAEWRhbXIgICAAAIP/AAEAAAAgc3R0cwAAAAAAAAACAAAAAQAAAKAAAAFTAAAAoAAAABRzdHN6AAAAAAAAAA0AAAFUAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAFUAAAAAQAAABRzdGNvAAAAAAAAAAEAAAAgAAAAGHVkdGEAAAAQU0RMTlNFUV9QTEFZ"  controls="controls" autobuffer="autobuffer">
</audio>
</div>

但是音频没有播放。你能告诉我我做了什么错吗?

  

注意:myAudio.mp3是存储在sdcard

中的录制音频文件

3 个答案:

答案 0 :(得分:8)

请尝试以下代码..

检查android支持的音频编解码器..

http://developer.android.com/guide/appendix/media-formats.html

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<audio controls="controls" autobuffer="autobuffer" autoplay="autoplay">
    <source src="data:audio/wav;base64,UklGRhwMAABXQVZFZm10IBAAAAABAAEAgD4AAIA+AAABAAgAZGF0Ya4LAACAgICAgICAgICAgICAg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d3h3d3h5eHl4eXh5eHl5eXp5enl6eXp7ent6e3p7e3t7fHt8e3x8fHx9fH1+fX59fn9+f35/gH+AgICAgICAgYGAgYKBgoGCgoKDgoOEg4SEhIWFhIWFhoWGhYaGhoaHhoeGh4aHhoeIh4iHiIeHiIeIh4iHiIeIiIiHiIeIh4iHiIiHiIeIh4iHiIeIh4eIh4eIh4aHh4aHhoeGh4aHhoWGhYaFhoWFhIWEhYSFhIWEhISDhIOEg4OCg4OCg4KDgYKCgYKCgYCBgIGAgYCBgICAgICAgICAf4B/f4B/gH+Af35/fn9+f35/fn1+fn19fn1+fX59fn19fX19fH18fXx9fH18fXx9fH18fXx8fHt8e3x7fHt8e3x7fHt8e3x7fHt8e3x7fHt8e3x7fHt8e3x8e3x7fHt8e3x7fHx8fXx9fH18fX5+fX59fn9+f35+f35/gH+Af4B/gICAgICAgICAgICAgYCBgIGAgIGAgYGBgoGCgYKBgoGCgYKBgoGCgoKDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KCgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGBgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCAgICBgIGAgYCBgIGAgYCBgIGAgYCBgExJU1RCAAAASU5GT0lDUkQMAAAAMjAwOC0wOS0yMQAASUVORwMAAAAgAAABSVNGVBYAAABTb255IFNvdW5kIEZvcmdlIDguMAAA" />
</audio>

</body>
</html>

答案 1 :(得分:0)

是的,没有。

除非用户事件提示(按钮点击等),否则Android不会播放音频。

如果人们可以让其他人的电话随时随地说出来,你可以想象出这种快乐的混乱。

一旦用户提示音频样本,显然可以在没有提示的情况下再次播放。

我希望Base64可以解决这个问题,但是没有雪茄。

答案 2 :(得分:0)

您错过了音频标签中的 source 标签 在https://www.w3schools.com/tags/tag_audio.asp

上查看有关它的更多信息

嵌入音频文件的简单方法是DATA URL是在线base64转换器。 我使用Base64 Online,您可以选择文件并获得多个结果,然后选择“音频标签” 你会得到这样的结果

<audio controls><source src="data:audio/mpeg;base64,SUQzAwAAAAA2PVRDT04AAAAFAAAAKDApAFRZRVIAAAA..."></audio>