安卓视频播放器完整项目.docx

上传人:b****5 文档编号:4097294 上传时间:2022-11-27 格式:DOCX 页数:45 大小:29.94KB
下载 相关 举报
安卓视频播放器完整项目.docx_第1页
第1页 / 共45页
安卓视频播放器完整项目.docx_第2页
第2页 / 共45页
安卓视频播放器完整项目.docx_第3页
第3页 / 共45页
安卓视频播放器完整项目.docx_第4页
第4页 / 共45页
安卓视频播放器完整项目.docx_第5页
第5页 / 共45页
点击查看更多>>
下载资源
资源描述

安卓视频播放器完整项目.docx

《安卓视频播放器完整项目.docx》由会员分享,可在线阅读,更多相关《安卓视频播放器完整项目.docx(45页珍藏版)》请在冰豆网上搜索。

安卓视频播放器完整项目.docx

安卓视频播放器完整项目

安卓视频播放器

该项目是自己学习阶段研发的,如果有什么不足之处,希望还能共同探,按钮和背景图片,还需要自己找,下面上代码

欢迎动画,WelcomeActivity.Java文件

package.iotek;

importandroid.app.Activity;

importandroid.content.Intent;

importandroid.os.Bundle;

importandroid.view.Window;

importandroid.view.WindowManager;

publicclassWelcomeActivityextendsActivity{

@Override

protectedvoidonCreate(BundlesavedInstanceState){

//TODOAuto-generatedmethodstub

super.onCreate(savedInstanceState);

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.welcome);

newMyWelcome().start();

}

classMyWelcomeextendsThread{

@Override

publicvoidrun(){

try{

sleep(3000);

Intentintent=newIntent(WelcomeActivity.this,VideoPlayerActivity.class);

startActivity(intent);

}catch(InterruptedExceptione){

//TODOAuto-generatedcatchblock

e.printStackTrace();

}

}

}

@Override

protectedvoidonStop(){

finish();

super.onStop();

}

}

欢迎动画配置文件welcome.xml

xmlversion="1.0"encoding="utf-8"?

>

android="

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

android:

background="@drawable/welcome"

android:

orientation="vertical">

三秒后进行跳转,进入界面,利用TabHost,VideoPlayerActivity代码如下

package.iotek;

import.adapter.OverwriteSimpleCursorAdapter;

import.adapter.OverwriterSimAdapter;

importandroid.app.TabActivity;

importandroid.content.Context;

importandroid.content.Intent;

importandroid.content.pm.PackageManager.NameNotFoundException;

importandroid.os.Bundle;

importandroid.view.Window;

importandroid.view.WindowManager;

importandroid.widget.SimpleAdapter;

importandroid.widget.SimpleCursorAdapter;

importandroid.widget.TabHost;

importandroid.widget.TabHost.OnTabChangeListener;

importandroid.widget.TabHost.TabSpec;

publicclassVideoPlayerActivityextendsTabActivity{

/**Calledwhentheactivityisfirstcreated.*/

staticbooleanflag;

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.main);

try{

//获取ShareActivity上下文

VideoList.context=createPackageContext(".iotek",Context.CONTEXT_IGNORE_SECURITY);

VideoList.share=VideoList.context.getSharedPreferences("setupadapter",VideoList.context.MODE_WORLD_READABLE);

VideoList.editor=VideoList.share.edit();

}catch(NameNotFoundExceptione){

e.printStackTrace();

}

if(VideoList.share.getString("setupadapter","off").equals("on")){

flag=true;

}

if(VideoList.share.getString("setupadapter","off").equals("off")){

flag=false;

}

VideoList.helper=newDbhelper(this,"/mnt/sdcard/videoinfo.db",null,1);

//设置为可读

//VideoList.db=VideoList.helper.getReadableDatabase();

TabHosttabHost=getTabHost();

//创建选项卡

TabSpeclocalVideo=tabHost.newTabSpec("localvideo");

TabSpecvideoList=tabHost.newTabSpec("videoList");

//设置选项卡名称

localVideo.setIndicator("加载本地文件");

videoList.setIndicator("播放列表");

tabHost.setOnTabChangedListener(newOnTabChangeListener(){

@Override

publicvoidonTabChanged(StringtabId){

//TODOAuto-generatedmethodstub

}

});

IntentintentLocal=newIntent(getApplicationContext(),ShowList.class);

IntentintentList=newIntent(getApplicationContext(),VideoList.class);

localVideo.setContent(intentLocal);

videoList.setContent(intentList);

//添加选项卡

tabHost.addTab(localVideo);

tabHost.addTab(videoList);

//设置监听

tabHost.setOnTabChangedListener(newOnTabChangeListener(){

@Override

publicvoidonTabChanged(StringtabId){

//TODOAuto-generatedmethodstub

booleanf=tabId.equals("videoList");

booleanb=tabId.equals("localvideo");

if(f){

if(flag){

VideoList.db=VideoList.helper.getReadableDatabase();

Stringsql="select*fromvideoinfo";

VideoList.cursor=VideoList.db.rawQuery(sql,null);

VideoList.adapter=newOverwriteSimpleCursorAdapter(getApplicationContext(),R.layout.show,VideoList.cursor,

newString[]{"path","videoname"},

newint[]{R.id.picture,R.id.videoname});

VideoList.videoList.setAdapter(VideoList.adapter);

}if(!

flag){

VideoList.db=VideoList.helper.getReadableDatabase();

Stringsql="select*fromvideoinfo";

VideoList.cursor=VideoList.db.rawQuery(sql,null);

VideoList.adapter=newSimpleCursorAdapter(getApplicationContext(),R.layout.show,VideoList.cursor,

newString[]{"path","videoname"},

newint[]{R.id.picture,R.id.videoname});

VideoList.videoList.setAdapter(VideoList.adapter);

}

}

if(b){

if(flag){

OverwriterSimAdapteradapter=newOverwriterSimAdapter(

getApplicationContext(),ShowList.listItems,R.layout.filelist,

newString[]{"filename","icon","modify"},newint[]{

R.id.file_name,R.id.icon,R.id.file_modify});

ShowList.filesList.setAdapter(adapter);

}if(!

flag){

SimpleAdapteradapter=newSimpleAdapter(

getApplicationContext(),ShowList.listItems,R.layout.filelist,

newString[]{"filename","icon","modify"},newint[]{

R.id.file_name,R.id.icon,R.id.file_modify});

ShowList.filesList.setAdapter(adapter);

}

}

}

});

}

@Override

protectedvoidonDestroy(){

//VideoList.db.close();

//VideoList.cursor.close();

super.onDestroy();

}

}

配置文件main.xml

xmlversion="1.0"encoding="utf-8"?

>

android="

android:

id="@android:

id/tabhost"

android:

layout_width="fill_parent"

android:

layout_height="fill_parent">

android:

orientation="vertical"

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

android:

padding="5dp">

android:

id="@android:

id/tabs"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

background="#00000000"

/>

android:

id="@android:

id/tabcontent"

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

android:

padding="5dp"/>

遍历内存卡ShowList代码

package.iotek;

importjava.io.File;

importjava.util.ArrayList;

importjava.util.HashMap;

importjava.util.List;

importjava.util.Map;

import.adapter.OverwriterSimAdapter;

importandroid.app.Activity;

importandroid.content.Context;

importandroid.content.pm.PackageManager.NameNotFoundException;

importandroid.os.Bundle;

importandroid.view.View;

importandroid.widget.AdapterView;

importandroid.widget.AdapterView.OnItemClickListener;

importandroid.widget.Button;

importandroid.widget.LinearLayout;

importandroid.widget.ListView;

importandroid.widget.SimpleAdapter;

importandroid.widget.TextView;

importandroid.widget.Toast;

publicclassShowListextendsActivity{

privateTextViewfilepath;

staticListViewfilesList;

privateButtonbackButton;

LinearLayoutlocalBack;

//记录当前的父文件夹

FilefloderParent;

inti;

//记录当前路径下的所有文件夹的文件数组

File[]dirFiles;

staticList>listItems;

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.showlist);

localBack=(LinearLayout)findViewById(R.id.localback);

localBack.setBackgroundResource(R.drawable.bleach3);

VideoList.helper=newDbhelper(this,"/mnt/sdcard/videoinfo.db",null,1);

//设置为可读

//VideoList.db=VideoList.helper.getReadableDatabase();

filesList=(ListView)this.findViewById(R.id.filesList);

filepath=(TextView)this.findViewById(R.id.filepath);

backButton=(Button)this.findViewById(R.id.backButton);

VideoList.helper=newDbhelper(this,"/mnt/sdcard/videoinfo.db",null,1);

//VideoList.db=VideoList.helper.getReadableDatabase();

try{

//获取ShareActivity上下文

VideoList.context=createPackageContext(".iotek",Context.CONTEXT_IGNORE_SECURITY);

VideoList.share=VideoList.context.getSharedPreferences("setupadapter",VideoList.context.MODE_WORLD_READABLE);

VideoList.editor=VideoList.share.edit();

}catch(NameNotFoundExceptione){

e.printStackTrace();

}

//对背景进行判断

if(VideoList.share.getString("picture","卡通").equals("卡通")){

localBack.setBackgroundResource(R.drawable.haizei);

}

if(VideoList.share.getString("picture","卡通").equals("风景")){

localBack.setBackgroundResource(R.drawable.suround2);

}

if(VideoList.share.getString("picture","卡通").equals("明星")){

localBack.setBackgroundResource(R.drawable.xuanya);

}

//获取系统的SDCard的目录

Fileroot=newFile("/mnt/sdcard/");

//如果SD卡存在的话

if(root.exists()){

floderParent=root;

dirFiles=root.listFiles();

//使用当前目录下的全部文件、文件夹来填充ListView

inflateListView(dirFiles);

}

filesList.setOnItemClickListener(newOnItemClickListener(){

@Override

publicvoidonItemClick(AdapterView

>adapterView,Viewview,

intposition,longid){

//如果用户单击了文件,直接返回,不做任何处理

if(dirFiles[position].isFile()){

i=position;

if(dirFiles[position].getPath().endsWith(".3gp")||dirFiles[position].getPath().endsWith(".mp4")

||dirFiles[position].getPath().endsWith(".mp3")||dirFiles[position].getPath().endsWith(".rmvb")){

/*if(currentFiles[position].getPath().equals(VideoList.cursor.getString

(1))){

Toast.makeText(getApplicationContext(),"你妹啊,路径名相同了",1000).show();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 冶金矿山地质

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1