zoukankan      html  css  js  c++  java
  • android 调用系统的音乐和视频播放器

    package com.eboy.testsystemaudiovideo;

    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Environment;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;

    public class MainActivity extends Activity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            
            Button btnAudio = (Button) this.findViewById(R.id.button1);        
            
            btnAudio.setOnClickListener(new OnClickListener() {
                
                @Override
                public void onClick(View v) {
                    Intent it = new Intent(Intent.ACTION_VIEW);
                    it.setDataAndType(Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/a.MP3"), "audio/MP3");
                    startActivity(it);            
                }
            });
            
            Button btnVideo = (Button) this.findViewById(R.id.button2);
            
            btnVideo.setOnClickListener(new OnClickListener() {
                
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.parse(Environment.getExternalStorageDirectory() + "/3.mp4"), "video/mp4");
                    startActivity(intent);
                }
            });
        }
    }

  • 相关阅读:
    [CSS揭秘]不规则投影
    [CSS揭秘]规则投影
    [CSS揭秘]伪随机背景
    [CSS揭秘]复杂的背景图案
    [CSS揭秘]条纹背景
    [CSS揭秘]连续的图像边框
    Git_Eclipse:[1]Git安装插件
    Git_常用命令
    上海 day38--多表查询、python操作MySQL
    上海 day37-- MySQL 单表查询,连表操作和子查询
  • 原文地址:https://www.cnblogs.com/ldq2016/p/5626620.html
Copyright © 2011-2022 走看看