Android:如何使用默认播放器播放音乐? [英] Android: How to stream music using default player?

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

问题描述

我想使用默认媒体播放器播放 mp3 歌曲.

I want to stream mp3 song using default media player.

我使用了 MIME 类型audio/*".

I used the MIME Type "audio/*".

Intent musicIntent = new Intent(android.content.Intent.ACTION_VIEW);
musicIntent.setType("audio/*");
startActivity(musicIntent);

那么如何通过默认音乐播放器播放音乐?

so how to stream music via default music player?

提前致谢

推荐答案

你可以像这样简单地将 url 传递给 Media Player,

You can simply pass the url to Media Player like this,

Uri myUri = Uri.parse("your url here");
Intent intent = new Intent(android.content.Intent.ACTION_VIEW); 
intent.setDataAndType(myUri, "audio/*"); 
startActivity(intent);

这篇关于Android:如何使用默认播放器播放音乐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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