Android 播放器 mov,Android 调用系统播放器
1、調(diào)用系統(tǒng)音樂(lè)播放器private void playAudio(String audioPath){
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(audioPath), "audio/mp3");
intent.setComponent(new ComponentName("com.android.music","com.android.music.MediaPlaybackActivity"));
startActivity(intent);
}private void playAudio(String audioPath){
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(audioPath), "audio/mp3");
intent.setComponent(new ComponentName("com.android.music","com.android.music.MediaPlaybackActivity"));
startActivity(intent);
}或者
Intent it = new Intent(Intent.ACTION_VIEW);
it.setDataAndType(Uri.parse("/sdcard/111.mp3"), "audio/mp3");
startActivity(it);Intent it = new Intent(Intent.ACTION_VIEW);
it.setDataAndType(Uri.parse("/sdcard/111.mp3"), "audio/mp3");
startActivity(it);
2、調(diào)用系統(tǒng)視頻播放器
方法一;private void playVideo(String videoPath){
Intent intent = new Intent(Intent.ACTION_VIEW);
String strend="";
if(videoPath.toLowerCase().endsWith(".mp4")){
strend="mp4";
}
else if(videoPath.toLowerCase().endsWith(".3gp")){
strend="3gp";
}
else if(videoPath.toLowerCase().endsWith(".mov")){
strend="mov";
}
else if(videoPath.toLowerCase().endsWith(".wmv")){
strend="wmv";
}
intent.setDataAndType(Uri.parse(videoPath), "video/"+strend);
startActivity(intent);
}
或者
Intent it = new Intent(Intent.ACTION_VIEW);
it.setDataAndType(Uri.parse("/sdcard/1122.mp4"), "video/mp4");
startActivity(it);
播放來(lái)自網(wǎng)絡(luò)多媒體文件
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
Intent mediaIntent = new Intent(Intent.ACTION_VIEW);
mediaIntent.setDataAndType(Uri.parse(url), mimeType);
startActivity(mediaIntent);
總結(jié)
以上是生活随笔為你收集整理的Android 播放器 mov,Android 调用系统播放器的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: web邮箱和客户端的区别
- 下一篇: 对服务器系统盘扩容,服务器系统盘扩容