如何关联.mp3文件Android Studio中 [英] How to associate .mp3 files in Android Studio

查看:2365
本文介绍了如何关联.mp3文件Android Studio中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想基于但是根据我的code列表视图项点击播放MP3文件去我跑我的应用程序会出现这个窗口等,由于缺乏我真的不知道的音频选项中的哪一个这些我需要为我的.mp3文件关联来选择。

I want to play an mp3 file based on a list view item click however based on my code went I run my app this window appears and so due to lack of an audio option I really don't know which one of these I need to select in order to associate my .mp3 files.

mainList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            //When clicked, go to specific activity
            if (position == 0) {
                if(mp.isPlaying())
                {
                    mp.stop();
                    mp.reset();
                }
                try {
                    AssetFileDescriptor afd = getAssets().openFd("chimes.mp3");
                    mp.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
                    mp.prepare();
                    mp.start();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });

推荐答案

您不必什么这只是用来打开主机上的文件关联,无关的设备。

You don't have to associate anything this is only used to OPEN the file on the host machine, has nothing to do with the device.

这篇关于如何关联.mp3文件Android Studio中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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