安卓:开放的默认音频播放器 [英] Android:open default audio player

查看:142
本文介绍了安卓:开放的默认音频播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个应用程序中,我不得不打开默认的音频播放器。我的意思是说在点击我要打开默认的音频播放器和音频播放器应该发挥特定的文件。我试过很多栈溢出的联系,但都在vain.Any帮助将AP preciated。我的code是如下:

I am making an app in which i have to open default audio player .I mean to say that on click i want to open default audio player and audio player should play specific file. I tried many stack overflow links but all in vain.Any help will be appreciated. My code is as follows:

Intent intent = new Intent(); 

            intent.setAction(android.content.Intent.ACTION_VIEW);  
            File file = new File(songs.get(position));  
            //String introURI = "file:///sdcard/"+".mp3";  
            intent.setDataAndType(Uri.fromFile(file), "audio/*");  
            startActivity(intent);

和宋玩家点击得到开放,但玩家提供消息的不支持此类型的文件

and on click of song player gets open but the player gives message that this type of file is not supported

推荐答案

当你想实现自己的媒体播放器MediaPlayer的类应该被使用。如果要使用现有的球员,你就必须推出相应的意图,例如:

The MediaPlayer class should be used when you want to implement your own media player. If you want to use an existing player, you'll have to launch the appropriate intent, for example:

Uri uri = Uri.parse("http://www.example.com/file.mp3");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

修改

如何获得当地的android文件URI

这篇关于安卓:开放的默认音频播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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