我怎样才能下载一首歌曲,并添加用户的音乐库? [英] How can I download a song and add it the user's music library?

查看:232
本文介绍了我怎样才能下载一首歌曲,并添加用户的音乐库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用程序需要下载一个MP3曲目,并将其添加到用户的媒体库。

My Android app needs to download a MP3 track and add it to the user's media library.

我还没有找到任何这良好的文档,所以我在想,如果它是作为存储在音乐目录的MP3一样简单?如果是这样,这将是用户的音乐目录的位置?

I haven't found any good documentation on this so I was wondering if it is as simple as storing the MP3 in the Music directory? If so, what would be the location of the user's music directory?

推荐答案

使用 MediaScanner

String mp3path = "Your MP3 file path";   
MediaScannerConnection msc = new MediaScannerConnection(yourcontext,
        new MediaScannerConnection.MediaScannerConnectionClient() {
            @Override
            public void onScanCompleted(String path, Uri uri){
                msc.disconnect();
            }
            @Override
            public void onMediaScannerConnected() {
                msc.scanFile(mp3path, null);
            }           
        });             
msc.connect();

这篇关于我怎样才能下载一首歌曲,并添加用户的音乐库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆