Skip to content

Commit eb5680c

Browse files
author
Oliver
committed
query media file info and sample/ for test
1 parent 5a0ba8b commit eb5680c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+93
-14
lines changed

bin/Player.apk

16.7 KB
Binary file not shown.

bin/classes.dex

1.92 KB
Binary file not shown.

bin/classes/sysu/ss/xu/FFmpeg.class

0 Bytes
Binary file not shown.
878 Bytes
Binary file not shown.
1.79 KB
Binary file not shown.
1.75 KB
Binary file not shown.
114 Bytes
Binary file not shown.

bin/classes/sysu/ss/xu/R$id.class

0 Bytes
Binary file not shown.

bin/classes/sysu/ss/xu/R$layout.class

0 Bytes
Binary file not shown.

bin/classes/sysu/ss/xu/R$string.class

0 Bytes
Binary file not shown.
1.64 KB
1.58 KB
1.28 KB
1.64 KB
1.58 KB
1.28 KB
1.64 KB
1.58 KB
1.28 KB

bin/resources.ap_

15.4 KB
Binary file not shown.

docRes/android player failed.png

381 KB

docRes/clicking ok.png

355 KB

docRes/demo.mpeg

5.8 MB
Binary file not shown.

docRes/fake media.png

380 KB

docRes/file system item.png

356 KB

docRes/in and out.png

340 KB

docRes/item selected.png

356 KB

docRes/media selected.png

394 KB

docRes/media selected2.png

380 KB

docRes/notes

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
a.mp4
2+
ipod.m4v
3+
mpeg2.m2v
4+
5+
is LEGAL media file
6+
7+
8+
9+
b.mp4 is a FAKE media file which is a text file with a ".mp4" suffix.
10+
11+
12+
auto orientation detect.
13+
slow.
14+
15+
example videos are from apple.com
16+
17+
a.mp4 is very big. so it's extremely slow.
18+
19+
Run on Ubuntu11.10, eclipse, Android AVD at API Level 14(4.0).
20+
21+
That's all.

docRes/query.png

397 KB

docRes/sample test.mpeg

5.44 MB
Binary file not shown.

docRes/samples.png

393 KB

gen/sysu/ss/xu/R.java

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public static final class drawable {
1414
public static final int desktop=0x7f020000;
1515
public static final int ic_launcher=0x7f020001;
1616
public static final int qq=0x7f020002;
17+
public static final int question_blue=0x7f020003;
18+
public static final int question_red=0x7f020004;
19+
public static final int question_redwhite=0x7f020005;
1720
}
1821
public static final class id {
1922
public static final int browseFilePanel=0x7f050001;

res/drawable-hdpi/question_blue.png

4.3 KB

res/drawable-hdpi/question_red.png

1.27 KB
1.42 KB

res/drawable-ldpi/question_blue.png

4.3 KB

res/drawable-ldpi/question_red.png

1.27 KB
1.42 KB

res/drawable-mdpi/question_blue.png

4.3 KB

res/drawable-mdpi/question_red.png

1.27 KB
1.42 KB

src/sysu/ss/xu/FFmpeg.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ public class FFmpeg {
2121
public native String play(String filePath);
2222

2323
// ffmpeg api
24-
public native void avRegisterAll();
25-
public native boolean avOpenInputFile(String filePath);
26-
public native boolean avFindStreamInfo();
27-
public native boolean findVideoStream();
28-
public native boolean avcodecFindDecoder();
29-
public native boolean avcodecOpen();
30-
public native void avcodecAllocFrame();
31-
public native void avFree();
32-
public native void avcodecClose();
33-
public native void avCloseInputFile();
24+
private native void avRegisterAll();
25+
private native boolean avOpenInputFile(String filePath);
26+
private native boolean avFindStreamInfo();
27+
private native boolean findVideoStream();
28+
private native boolean avcodecFindDecoder();
29+
private native boolean avcodecOpen();
30+
private native void avcodecAllocFrame();
31+
private native void avFree();
32+
private native void avcodecClose();
33+
private native void avCloseInputFile();
3434

3535
// functional call
3636
public native String getCodecName();

src/sysu/ss/xu/FileBrowser.java

+58-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
import android.app.Activity;
44
import android.graphics.Color;
5+
import android.graphics.drawable.Drawable;
6+
import android.text.SpannableString;
7+
import android.text.InputFilter.LengthFilter;
8+
import android.text.style.ImageSpan;
9+
import android.util.Log;
510
import android.view.LayoutInflater;
611
import android.view.View;
712
import android.view.View.OnClickListener;
813
import android.widget.LinearLayout;
914
import android.widget.TextView;
15+
import android.widget.Toast;
1016

1117
public class FileBrowser {
1218

@@ -20,6 +26,13 @@ public class FileBrowser {
2026

2127
private final int falseColor = Color.BLUE;
2228
private final int trueColor = Color.RED;
29+
private Drawable selectedIcon;
30+
private FFmpeg ffmpeg;
31+
private boolean isMediaFile;
32+
protected String codecName;
33+
protected int width;
34+
protected int height;
35+
protected String toastString;
2336

2437
public FileBrowser(Activity activity) {
2538
this.activity = activity;
@@ -28,6 +41,8 @@ public FileBrowser(Activity activity) {
2841

2942
selected = false;
3043
selectedIndex = -1;
44+
selectedIcon = activity.getResources().getDrawable(R.drawable.question_red);
45+
ffmpeg = FFmpeg.getInstance();
3146
}
3247

3348
public void setItems(String path, String[] items) {
@@ -50,30 +65,70 @@ private void pack() {
5065
for (int index = 0; index < length; index++) {
5166
fileView[index] = (LinearLayout) inflater.inflate(R.layout.file, null).findViewById(R.id.fileView);
5267

68+
/* textview[0] */
5369
TextView fileFlag = (TextView) fileView[index].getChildAt(0);
5470
fileFlag.setBackgroundColor(falseColor);
5571

72+
/* textview[1] */
5673
TextView text = (TextView) fileView[index].getChildAt(1);
5774
text.setText(items[index]);
58-
addListener(text, index, fileView);
75+
76+
if( ffmpeg.isMediaFile( path + "/" + items[index] ) )
77+
isMediaFile = true;
78+
else
79+
isMediaFile = false;
80+
addSelectEventListener(text, index, fileView, isMediaFile);
81+
if( isMediaFile == true ) {
82+
addQueryEventListener(fileFlag, text, index);
83+
}
5984
browseFilePanel.addView(fileView[index]);
6085
}
6186
}
6287

63-
private void addListener(TextView text, final int index, final LinearLayout[] fileView) {
88+
private void addQueryEventListener(TextView fileFlag, final TextView text, final int index) {
89+
fileFlag.setOnClickListener(new OnClickListener() {
90+
91+
@Override
92+
public void onClick(View v) {
93+
String filePath = path + "/" + items[index];
94+
95+
ffmpeg.openFile(filePath);
96+
codecName = ffmpeg.getCodecName();
97+
width = ffmpeg.getWidth();
98+
height = ffmpeg.getHeight();
99+
ffmpeg.cleanUp();
100+
101+
toastString = "Codec: " + codecName + " Width: " + width + " Height: " + height;
102+
103+
Toast.makeText(activity, toastString, Toast.LENGTH_LONG);
104+
text.setText(toastString);
105+
106+
}
107+
});
108+
}
109+
110+
private void addSelectEventListener(final TextView text, final int index, final LinearLayout[] fileView, final boolean isSelectedMediaFile) {
64111
text.setOnClickListener(new OnClickListener() {
65112

66113
@Override
67114
public void onClick(View v) {
68115
// TODO Auto-generated method stub
69116
if(selected == true) {
70117
fileView[selectedIndex].getChildAt(0).setBackgroundColor(falseColor);
118+
( (TextView) fileView[selectedIndex].getChildAt(1) ).setText(items[selectedIndex]);
71119

72120
selected = false;
73121
selectedIndex = -1;
74122
}
75-
123+
76124
fileView[index].getChildAt(0).setBackgroundColor(trueColor);
125+
126+
if( isSelectedMediaFile == true ) {
127+
fileView[index].getChildAt(0).setBackgroundDrawable(selectedIcon);
128+
}
129+
130+
131+
77132

78133
selected = true;
79134
selectedIndex = index;

src/sysu/ss/xu/PlayerActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void onDraw(Canvas canvas){
9191
if(nativePixels != null) {
9292
buffer = ByteBuffer.wrap(nativePixels);
9393
bitmap.copyPixelsFromBuffer(buffer);
94-
}
94+
}
9595

9696
canvas.drawBitmap(bitmap, 0, 0, p);
9797
}

0 commit comments

Comments
 (0)