安卓视频播放器完整项目Word文档格式.docx

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

安卓视频播放器完整项目Word文档格式.docx

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

安卓视频播放器完整项目Word文档格式.docx

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

startActivity(intent);

}catch(InterruptedExceptione){

//TODOAuto-generatedcatchblock

e.printStackTrace();

}

}

protectedvoidonStop(){

finish();

super.onStop();

}

欢迎动画配置文件welcome.xml

<

?

xmlversion="

1.0"

encoding="

utf-8"

>

LinearLayoutxmlns:

android="

android:

layout_width="

fill_parent"

layout_height="

background="

@drawable/welcome"

orientation="

vertical"

>

/LinearLayout>

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

import.adapter.OverwriteSimpleCursorAdapter;

import.adapter.OverwriterSimAdapter;

importandroid.app.TabActivity;

importandroid.content.Context;

importandroid.content.pm.PackageManager.NameNotFoundException;

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("

"

off"

).equals("

on"

)){

flag=true;

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(){

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);

//设置监听

@Override

publicvoidonTabChanged(StringtabId){

//TODOAuto-generatedmethodstub

booleanf=tabId.equals("

booleanb=tabId.equals("

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();

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

if(b){

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);

SimpleAdapteradapter=newSimpleAdapter(

});

protectedvoidonDestroy(){

//VideoList.db.close();

//VideoList.cursor.close();

super.onDestroy();

配置文件main.xml

TabHostxmlns:

id="

@android:

id/tabhost"

<

LinearLayout

padding="

5dp"

TabWidget

id/tabs"

wrap_content"

#00000000"

/>

FrameLayout

id/tabcontent"

/TabHost>

遍历内存卡ShowList代码

importjava.io.File;

importjava.util.ArrayList;

importjava.util.HashMap;

importjava.util.List;

importjava.util.Map;

importandroid.view.View;

importandroid.widget.AdapterView;

importandroid.widget.AdapterView.OnItemClickListener;

importandroid.widget.Button;

importandroid.widget.LinearLayout;

importandroid.widget.ListView;

importandroid.widget.TextView;

importandroid.widget.Toast;

publicclassShowListextendsActivity{

privateTextViewfilepath;

staticListViewfilesList;

privateButtonbackButton;

LinearLayoutlocalBack;

//记录当前的父文件夹

FilefloderParent;

inti;

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

File[]dirFiles;

staticList<

Map<

String,Object>

listItems;

super.onCreate(savedInstanceState);

setContentView(R.layout.showlist);

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

localBack.setBackgroundResource(R.drawable.bleach3);

VideoList.helper=newDbhelper(this,"

//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);

try{

//获取ShareActivity上下文

VideoList.context=createPackageContext("

VideoList.share=VideoList.context.getSharedPreferences("

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

//对背景进行判断

if(VideoList.share.getString("

picture"

卡通"

localBack.setBackgroundResource(R.drawable.haizei);

风景"

localBack.setBackgroundResource(R.drawable.suround2);

明星"

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(){

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"

.rmvb"

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

(1))){

Toast.makeText(getApplicationContext(),"

你妹啊,路径名相同了"

1000).show();

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

当前位置:首页 > 表格模板 > 调查报告

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

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