Skip to content

Commit 8c76920

Browse files
committed
PImage will be initialized in the child class
Signed-off-by: Umair Khan <[email protected]>
1 parent 9c4320d commit 8c76920

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/in/omerjerk/processing/video/android/Capture.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ public Capture(PApplet parent) {
3333
}
3434

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

3843
activity.runOnUiThread(new Runnable() {
3944
@Override

src/in/omerjerk/processing/video/android/Movie.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package in.omerjerk.processing.video.android;
22

33
import in.omerjerk.processing.video.android.callbacks.MediaPlayerHandlerCallback;
4+
import android.media.MediaMetadataRetriever;
45
import android.media.MediaPlayer;
56
import android.os.Handler;
67
import android.os.Looper;
@@ -13,12 +14,14 @@ public class Movie extends VideoBase implements MediaPlayerHandlerCallback {
1314
private MediaPlayerHandler handler;
1415
private MediaPlayer player;
1516

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+
2225
new Thread(new Runnable() {
2326
@Override
2427
public void run() {

src/in/omerjerk/processing/video/android/VideoBase.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,9 @@ public static void log(String log) {
5050
public abstract void onResume();
5151
public abstract void onPause();
5252

53-
public VideoBase(PApplet parent, int width, int height) {
53+
public VideoBase(PApplet parent) {
5454
super();
5555
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);
6256

6357
parent.registerMethod("pause", this);
6458
parent.registerMethod("resume", this);

0 commit comments

Comments
 (0)