Skip to content

Commit

Permalink
before full implementation of new libmediaplayer addons
Browse files Browse the repository at this point in the history
  • Loading branch information
havlenapetr committed Jul 25, 2010
1 parent d323e8d commit edc5500
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/com/media/ffmpeg/FFMpeg.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.Context;
import android.util.Log;

import com.media.ffmpeg.android.FFMpegMovieViewAndroid;
import com.media.ffmpeg.android.FFMpegPlayerAndroid;
import com.media.ffmpeg.config.FFMpegConfig;

Expand Down Expand Up @@ -106,8 +107,8 @@ public void setConfig(FFMpegConfig config) {
native_av_parse_options(new String[] {"ffmpeg", mOutputFile.getFile().getAbsolutePath()});
}

public FFMpegPlayerAndroid getPlayer(Context context) {
return new FFMpegPlayerAndroid(context);
public FFMpegMovieViewAndroid getMovieView(Context context) {
return new FFMpegMovieViewAndroid(context);
}

public void setBitrate(String bitrate) {
Expand Down
18 changes: 11 additions & 7 deletions src/com/media/ffmpeg/FFMpegPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void setDisplay(SurfaceHolder sh) {
* @throws IllegalStateException if it is called in an invalid state
*/
public void start() throws IllegalStateException {
stayAwake(true);
//stayAwake(true);
_start();
}

Expand All @@ -127,7 +127,7 @@ public void start() throws IllegalStateException {
* initialized.
*/
public void stop() throws IllegalStateException {
stayAwake(false);
//stayAwake(false);
_stop();
}

Expand All @@ -138,7 +138,7 @@ public void stop() throws IllegalStateException {
* initialized.
*/
public void pause() throws IllegalStateException {
stayAwake(false);
//stayAwake(false);
_pause();
}

Expand Down Expand Up @@ -194,6 +194,7 @@ public void setScreenOnWhilePlaying(boolean screenOn) {
}
}

/*
private void stayAwake(boolean awake) {
if (mWakeLock != null) {
if (awake && !mWakeLock.isHeld()) {
Expand All @@ -205,6 +206,7 @@ private void stayAwake(boolean awake) {
mStayAwake = awake;
updateSurfaceScreenOn();
}
*/

private void updateSurfaceScreenOn() {
if (mSurfaceHolder != null) {
Expand Down Expand Up @@ -326,7 +328,7 @@ private void updateSurfaceScreenOn() {
* done using the MediaPlayer.
*/
public void release() {
stayAwake(false);
//stayAwake(false);
updateSurfaceScreenOn();
_release();
}
Expand All @@ -337,7 +339,7 @@ public void release() {
* data source and calling prepare().
*/
public void reset() {
stayAwake(false);
//stayAwake(false);
_reset();
}

Expand All @@ -356,7 +358,7 @@ public boolean suspend() {
return false;
}

stayAwake(false);
//stayAwake(false);

// make sure none of the listeners get called anymore
//mEventHandler.removeCallbacksAndMessages(null);
Expand All @@ -376,10 +378,12 @@ public boolean resume() {
return false;
}

/*
if (isPlaying()) {
stayAwake(true);
}

*/

return true;
}

Expand Down
7 changes: 6 additions & 1 deletion src/com/media/ffmpeg/android/FFMpegMovieViewAndroid.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.media.ffmpeg.android;

import java.io.IOException;

import com.media.ffmpeg.FFMpegPlayer;

import android.content.Context;
Expand Down Expand Up @@ -50,6 +52,10 @@ private void attachMediaController() {
mMediaController.setEnabled(true);
}

public void setVideoPath(String filePath) throws IllegalArgumentException, IllegalStateException, IOException {
mPlayer.setDataSource(filePath);
}

/**
* initzialize player
*/
Expand Down Expand Up @@ -138,5 +144,4 @@ public int getBufferPercentage() {
return 0;
}
};

}
28 changes: 18 additions & 10 deletions src/cz/havlena/ffmpeg/ui/FFMpegPlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.media.ffmpeg.FFMpeg;
import com.media.ffmpeg.FFMpegException;
import com.media.ffmpeg.IFFMpegPlayer;
import com.media.ffmpeg.android.FFMpegPlayerAndroid;
import com.media.ffmpeg.android.FFMpegMovieViewAndroid;

import android.app.Activity;
import android.content.Context;
Expand All @@ -21,10 +21,10 @@

public class FFMpegPlayerActivity extends Activity {
private static final String TAG = "FFMpegPlayerActivity";
private static final String LICENSE = "This software uses libraries from the FFmpeg project under the LGPLv2.1";
//private static final String LICENSE = "This software uses libraries from the FFmpeg project under the LGPLv2.1";

private FFMpegPlayerAndroid mPlayer;
private WakeLock mWakeLock;
private FFMpegMovieViewAndroid mMovieView;
//private WakeLock mWakeLock;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -36,19 +36,25 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "Not specified video file");
finish();
} else {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
//PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
//mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);

try {
FFMpeg ffmpeg = new FFMpeg();
mPlayer = ffmpeg.getPlayer(this);
mMovieView = ffmpeg.getMovieView(this);
try {
mPlayer.setVideoPath(filePath);
mPlayer.setListener(new FFMpegPlayerHandler());
mMovieView.setVideoPath(filePath);
} catch (IllegalArgumentException e) {
Log.e(TAG, "Can't set video: " + e.getMessage());
FFMpegMessageBox.show(this, e);
} catch (IllegalStateException e) {
Log.e(TAG, "Can't set video: " + e.getMessage());
FFMpegMessageBox.show(this, e);
} catch (IOException e) {
Log.e(TAG, "Can't set video: " + e.getMessage());
FFMpegMessageBox.show(this, e);
}
setContentView(mPlayer);
setContentView(mMovieView);
} catch (FFMpegException e) {
Log.d(TAG, "Error when inicializing ffmpeg: " + e.getMessage());
FFMpegMessageBox.show(this, e);
Expand All @@ -57,6 +63,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
Expand Down Expand Up @@ -142,4 +149,5 @@ public void onStop() {
}
}
*/
}

0 comments on commit edc5500

Please sign in to comment.