File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
src/in/omerjerk/processing/video/android Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,12 @@ public Capture(PApplet parent) {
33
33
}
34
34
35
35
public Capture (final PApplet parent , int width , int height ) {
36
- super (parent , width , height );
36
+ super (parent );
37
+ if (width == -1 || height == -1 ) {
38
+ width = 720 ;
39
+ height = 720 ;
40
+ }
41
+ init (width , height , ARGB );
37
42
38
43
activity .runOnUiThread (new Runnable () {
39
44
@ Override
Original file line number Diff line number Diff line change 1
1
package in .omerjerk .processing .video .android ;
2
2
3
3
import in .omerjerk .processing .video .android .callbacks .MediaPlayerHandlerCallback ;
4
+ import android .media .MediaMetadataRetriever ;
4
5
import android .media .MediaPlayer ;
5
6
import android .os .Handler ;
6
7
import android .os .Looper ;
@@ -13,12 +14,14 @@ public class Movie extends VideoBase implements MediaPlayerHandlerCallback {
13
14
private MediaPlayerHandler handler ;
14
15
private MediaPlayer player ;
15
16
16
- public Movie (PApplet parent ) {
17
- this (parent , -1 , -1 );
18
- }
19
-
20
- public Movie (PApplet parent , int width , int height ) {
21
- super (parent , width , height );
17
+ public Movie (PApplet parent , String fileName ) {
18
+ super (parent );
19
+ MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever ();
20
+ metaRetriever .setDataSource (fileName );
21
+ String height = metaRetriever .extractMetadata (MediaMetadataRetriever .METADATA_KEY_VIDEO_HEIGHT );
22
+ String width = metaRetriever .extractMetadata (MediaMetadataRetriever .METADATA_KEY_VIDEO_WIDTH );
23
+ init (Integer .valueOf (width ), Integer .valueOf (height ), ARGB );
24
+
22
25
new Thread (new Runnable () {
23
26
@ Override
24
27
public void run () {
Original file line number Diff line number Diff line change @@ -50,15 +50,9 @@ public static void log(String log) {
50
50
public abstract void onResume ();
51
51
public abstract void onPause ();
52
52
53
- public VideoBase (PApplet parent , int width , int height ) {
53
+ public VideoBase (PApplet parent ) {
54
54
super ();
55
55
this .parent = parent ;
56
- if (width == -1 || height == -1 ) {
57
- //TODO: Temp hack. Needs to be handled intelligently.
58
- width = 720 ;
59
- height = 1280 ;
60
- }
61
- init (width , height , ARGB );
62
56
63
57
parent .registerMethod ("pause" , this );
64
58
parent .registerMethod ("resume" , this );
You can’t perform that action at this time.
0 commit comments