android视频播放器源码Word下载.docx

上传人:b****2 文档编号:908608 上传时间:2023-04-29 格式:DOCX 页数:17 大小:181.41KB
下载 相关 举报
android视频播放器源码Word下载.docx_第1页
第1页 / 共17页
android视频播放器源码Word下载.docx_第2页
第2页 / 共17页
android视频播放器源码Word下载.docx_第3页
第3页 / 共17页
android视频播放器源码Word下载.docx_第4页
第4页 / 共17页
android视频播放器源码Word下载.docx_第5页
第5页 / 共17页
android视频播放器源码Word下载.docx_第6页
第6页 / 共17页
android视频播放器源码Word下载.docx_第7页
第7页 / 共17页
android视频播放器源码Word下载.docx_第8页
第8页 / 共17页
android视频播放器源码Word下载.docx_第9页
第9页 / 共17页
android视频播放器源码Word下载.docx_第10页
第10页 / 共17页
android视频播放器源码Word下载.docx_第11页
第11页 / 共17页
android视频播放器源码Word下载.docx_第12页
第12页 / 共17页
android视频播放器源码Word下载.docx_第13页
第13页 / 共17页
android视频播放器源码Word下载.docx_第14页
第14页 / 共17页
android视频播放器源码Word下载.docx_第15页
第15页 / 共17页
android视频播放器源码Word下载.docx_第16页
第16页 / 共17页
android视频播放器源码Word下载.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

android视频播放器源码Word下载.docx

《android视频播放器源码Word下载.docx》由会员分享,可在线阅读,更多相关《android视频播放器源码Word下载.docx(17页珍藏版)》请在冰点文库上搜索。

android视频播放器源码Word下载.docx

android.widget.ImageButton;

13.import 

android.widget.MediaController;

14.import 

android.widget.TextView;

15.import 

android.widget.VideoView;

16. 

17.public 

class 

VideoPlay 

extends 

Activity 

18. 

19. 

private 

VideoView 

videoView;

20. 

static 

int 

index 

0;

21. 

22. 

@Override 

23. 

public 

void 

onCreate(Bundle 

savedInstanceState) 

24. 

super.onCreate(savedInstanceState);

25. 

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

26. 

setContentView(R.layout.main);

27. 

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

WindowManager.LayoutParams.FLAG_FULLSCREEN);

// 

28. 

//设置标题栏的布局 

29. 

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, 

R.layout.titlebar);

30. 

//这个空间暂时没用 

31. 

final 

TextView 

titleTV 

(TextView) 

findViewById(R.id.title);

32. 

titleTV.setText("

"

);

33. 

ImageButton 

titleButton 

(ImageButton) 

findViewById(R.id.titleButton);

34. 

//为按钮添加鼠标点击事件 

35. 

titleButton.setOnClickListener(new 

OnClickListener() 

36. 

37. 

onClick(View 

v) 

38. 

Intent 

intent 

new 

Intent();

39. 

intent.setClass(VideoPlay.this, 

MyFile.class);

40. 

//打开MyFile 

activity 

41. 

startActivity(intent);

42. 

43. 

});

44. 

getIntent();

45. 

String 

value 

intent.getDataString();

46. 

videoView 

(VideoView) 

findViewById(R.id.VideoView01);

47. 

if(value==null){ 

48. 

//加载默认视频 

49. 

videoView.setVideoURI(Uri.parse("

android.resource:

//com.bestaone/"

R.drawable.coco));

50. 

}else{ 

51. 

//通过文件浏览器传过来的视频路径,播放 

52. 

videoView.setVideoPath(value);

53. 

54. 

videoView.setMediaController(new 

MediaController(VideoPlay.this));

55. 

videoView.requestFocus();

56. 

57. 

58. 

//启动 

59. 

60. 

protected 

onStart() 

61. 

super.onStart();

62. 

Log.i("

mp4"

 

@@@ 

on 

start"

63. 

64. 

65. 

66. 

onResume() 

67. 

super.onResume();

68. 

videoView.seekTo(index);

69. 

videoView.start();

70. 

resume"

71. 

72. 

73. 

//暂停 

74. 

75. 

onPause() 

76. 

super.onPause();

77. 

pause"

78. 

79. 

80. 

//停止 

81. 

82. 

onStop() 

83. 

super.onStop();

84. 

videoView.pause();

85. 

//在这里记住视频播放的位置,当屏幕横竖切换的时候可以从记录点继续播放 

86. 

videoView.getCurrentPosition();

87. 

stop"

88. 

89. 

90. 

//销毁 

91. 

92. 

onDestroy() 

93. 

super.onDestroy();

94. 

// 

videoView.destroyDrawingCache();

95. 

96. 

destroy"

97. 

98. 

99.} 

MyFile.java

java.io.File;

java.util.ArrayList;

java.util.List;

6. 

android.app.ListActivity;

android.view.KeyEvent;

android.widget.AdapterView;

android.widget.AdapterView.OnItemLongClickListener;

android.widget.Button;

16.import 

android.widget.EditText;

17.import 

18.import 

android.widget.ListView;

19.import 

20.import 

android.widget.Toast;

22.public 

MyFile 

ListActivity 

implements 

OnItemLongClickListener 

//支持的视频格式 

String[][] 

FILE_MapTable 

{后缀名, 

MIME类型} 

.3gp"

video/3gpp"

}, 

.mov"

video/quicktime"

.avi"

video/x-msvideo"

.rmvb"

audio/x-pn-realaudio"

.wmv"

audio/x-ms-wmv"

};

List<

String>

items 

null;

items:

存放显示的名称 

paths 

paths:

存放文件路径 

sizes 

sizes:

文件大小 

rootPath 

/"

;

rootPath:

起始文件夹 

path_edit;

rb_qry;

isZoom 

isOpen 

/** 

重写返回键功能:

返回上一级文件夹 

*/ 

boolean 

onKeyDown(int 

keyCode, 

KeyEvent 

event) 

是否触发按键为back键 

if 

(keyCode 

== 

KeyEvent.KEYCODE_BACK) 

path_edit 

(EditText) 

findViewById(R.id.path_edit);

File 

file 

File(path_edit.getText().toString());

(rootPath.equals(path_edit.getText().toString())) 

return 

super.onKeyDown(keyCode, 

event);

else 

getFileDir(file.getParent());

true;

如果不是back键正常响应 

icicle) 

super.onCreate(icicle);

setContentView(R.layout.myfile);

rb_qry 

findViewById(R.id.qry_button);

rb_qry.setOnClickListener(listener_qry);

getListView().setOnItemLongClickListener(this);

getFileDir(rootPath);

Button.OnClickListener 

listener_qry 

Button.OnClickListener() 

arg0) 

(file.exists()) 

(file.isFile()) 

openFile(file);

getFileDir(path_edit.getText().toString());

Toast.makeText(MyFile.this, 

找不到该位置,请确定位置是否正确!

Toast.LENGTH_SHORT).show();

设置ListItem被点击时要做的动作 

onListItemClick(ListView 

l, 

View 

v, 

position, 

long 

id) 

99. 

File(paths.get(position));

100. 

fileOrDirHandle(file);

101. 

102. 

103. 

104. 

105. 

处理文件或者目录的方法 

106. 

@param 

file 

107. 

flag 

108. 

109. 

fileOrDirHandle(final 

file) 

110. 

(file.isDirectory()) 

111. 

getFileDir(file.getPath());

112. 

113. 

114. 

115. 

116. 

117. 

118. 

取得文件结构的方法 

119. 

filePath 

120. 

121. 

getFileDir(String 

filePath) 

122. 

/* 

设置目前所在路径 

123. 

path_edit.setText(filePath);

124. 

ArrayList<

();

125. 

126. 

127. 

File(filePath);

128. 

File[] 

files 

f.listFiles();

129. 

(files 

!

null) 

130. 

将所有文件添加ArrayList中 

131. 

for 

(int 

<

files.length;

i++) 

132. 

(files[i].isDirectory()) 

133. 

items.add(files[i].getName());

134. 

paths.add(files[i].getPath());

135. 

sizes.add("

136. 

137. 

138. 

139. 

140. 

(files[i].isFile()) 

141. 

fileName 

files[i].getName();

142. 

fileName.lastIndexOf("

."

143. 

if(index>

0){ 

144. 

endName 

fileName.substring(index,fileName.length()).toLowerCase();

145. 

type 

146. 

for(int 

x=0;

x<

FILE_MapTable.length;

x++){ 

147. 

//支持的格式,才会在文件浏览器中显示 

148. 

if(endName.equals(FILE_MapTable[x][0])){ 

149. 

FILE_MapTable[x][1];

150. 

break;

151. 

152. 

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

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2