android从byte[]字节数组中播放mp3音乐

2021-01-06 23:04:11


android从byte[]字节数组中播放mp3音乐

private void playMp3(byte[] mp3SoundByteArray) {

    try {

        // create temp file that will hold byte array

        File tempMp3 = File.createTempFile("kurchina", "mp3", getCacheDir());

        tempMp3.deleteOnExit();

        FileOutputStream fos = new FileOutputStream(tempMp3);

        fos.write(mp3SoundByteArray);

        fos.close();

 

        // Tried reusing instance of media player

        // but that resulted in system crashes...  

        MediaPlayer mediaPlayer = new MediaPlayer();

 

        // Tried passing path directly, but kept getting 

        // "Prepare failed.: status=0x1"

        // so using file descriptor instead

        FileInputStream fis = new FileInputStream(tempMp3);

        mediaPlayer.setDataSource(fis.getFD());

 

        mediaPlayer.prepare();

        mediaPlayer.start();

    } catch (IOException ex) {

        String s = ex.toString();

        ex.printStackTrace();

    }

}


  • 2019-04-30 11:23:36

    elasticsearch和analysis-ik的安装使用

    全文搜索和中文分词主要介绍了两组全文搜索加中文分词方案; TNTSearch+jieba-php这套组合对于博客这类的小项目基本够用了;

  • 2019-04-30 11:42:24

    php7+laravel+coreseek(sphinx)中文搜索初步实现(Linux)

    官网www.coreseek.cn已不能下载,所以需从网上找资源, 注意的一点是,笔者安装coreseek-3.2.14版本后,使用时提示client版本高于server版本的错误, php的sphinx扩展,为使用者,为client;coreseek是系统服务,为server

  • 2019-04-30 13:55:13

    浅谈mysql fulltext全文索引优缺点

    为什么会注意到mysql的fulltext? nima, 还是上次innodb转成tokudb引擎的事,这次alter修改表引擎的时候,提示percona tokudb是不支持fulltext索引的.

  • 2019-04-30 18:56:52

    elasticsearch文档操作

    使用了Elasticsearch提供的一整套强大的REST API,本文继续来看通过这一套API如何完成文档的基本操作。