Commit e5b92522 authored by Thomas Guillem's avatar Thomas Guillem

update with last LibVLC API

parent 725ec7aa
...@@ -5,7 +5,7 @@ buildscript { ...@@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.1.3' classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
......
...@@ -32,7 +32,7 @@ import org.videolan.libvlc.MediaPlayer; ...@@ -32,7 +32,7 @@ import org.videolan.libvlc.MediaPlayer;
import java.util.ArrayList; import java.util.ArrayList;
public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback { public class JavaActivity extends AppCompatActivity implements IVLCVout.OnNewVideoLayoutListener {
private static final boolean ENABLE_SUBTITLES = true; private static final boolean ENABLE_SUBTITLES = true;
private static final String TAG = "JavaActivity"; private static final String TAG = "JavaActivity";
private static final String SAMPLE_URL = "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v"; private static final String SAMPLE_URL = "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v";
...@@ -97,8 +97,7 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback ...@@ -97,8 +97,7 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback
vlcVout.setVideoView(mVideoSurface); vlcVout.setVideoView(mVideoSurface);
if (mSubtitlesSurface != null) if (mSubtitlesSurface != null)
vlcVout.setSubtitlesView(mSubtitlesSurface); vlcVout.setSubtitlesView(mSubtitlesSurface);
vlcVout.attachViews(); vlcVout.attachViews(this);
mMediaPlayer.getVLCVout().addCallback(this);
Media media = new Media(mLibVLC, Uri.parse(SAMPLE_URL)); Media media = new Media(mLibVLC, Uri.parse(SAMPLE_URL));
mMediaPlayer.setMedia(media); mMediaPlayer.setMedia(media);
...@@ -138,7 +137,6 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback ...@@ -138,7 +137,6 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback
mMediaPlayer.stop(); mMediaPlayer.stop();
mMediaPlayer.getVLCVout().detachViews(); mMediaPlayer.getVLCVout().detachViews();
mMediaPlayer.getVLCVout().removeCallback(this);
} }
private void updateVideoSurfaces() { private void updateVideoSurfaces() {
if (mVideoWidth * mVideoHeight == 0) if (mVideoWidth * mVideoHeight == 0)
...@@ -232,7 +230,7 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback ...@@ -232,7 +230,7 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override @Override
public void onNewLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) { public void onNewVideoLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
mVideoWidth = width; mVideoWidth = width;
mVideoHeight = height; mVideoHeight = height;
mVideoVisibleWidth = visibleWidth; mVideoVisibleWidth = visibleWidth;
...@@ -241,12 +239,4 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback ...@@ -241,12 +239,4 @@ public class JavaActivity extends AppCompatActivity implements IVLCVout.Callback
mVideoSarDen = sarDen; mVideoSarDen = sarDen;
updateVideoSurfaces(); updateVideoSurfaces();
} }
@Override
public void onSurfacesCreated(IVLCVout vlcVout) {
}
@Override
public void onSurfacesDestroyed(IVLCVout vlcVout) {
}
} }
...@@ -55,8 +55,6 @@ Java_org_videolan_nativesample_NativeActivity_nativeCreate( ...@@ -55,8 +55,6 @@ Java_org_videolan_nativesample_NativeActivity_nativeCreate(
static const char *pp_argv[] = { static const char *pp_argv[] = {
"-vvv", "-vvv",
"--aout", "android_audiotrack",
"--androidwindow-chroma", "RV32",
"--audio-resampler", "soxr", "--audio-resampler", "soxr",
}; };
p_ctx->p_libvlc = libvlc_new(sizeof(pp_argv)/sizeof(*pp_argv), pp_argv); p_ctx->p_libvlc = libvlc_new(sizeof(pp_argv)/sizeof(*pp_argv), pp_argv);
......
...@@ -27,11 +27,11 @@ import android.widget.FrameLayout; ...@@ -27,11 +27,11 @@ import android.widget.FrameLayout;
import android.widget.Toast; import android.widget.Toast;
import org.videolan.libvlc.AWindow; import org.videolan.libvlc.AWindow;
import org.videolan.libvlc.AWindowNativeHandler;
import org.videolan.libvlc.IVLCVout; import org.videolan.libvlc.IVLCVout;
@SuppressWarnings("JniMissingFunction") @SuppressWarnings("JniMissingFunction")
public class NativeActivity extends AppCompatActivity implements IVLCVout.Callback { public class NativeActivity extends AppCompatActivity implements IVLCVout.Callback,
IVLCVout.OnNewVideoLayoutListener {
private static final boolean ENABLE_SUBTITLES = true; private static final boolean ENABLE_SUBTITLES = true;
private static final String TAG = "NativeActivity"; private static final String TAG = "NativeActivity";
private static final int SURFACE_BEST_FIT = 0; private static final int SURFACE_BEST_FIT = 0;
...@@ -140,7 +140,7 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba ...@@ -140,7 +140,7 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba
mAWindow.setVideoView(mVideoSurface); mAWindow.setVideoView(mVideoSurface);
if (mSubtitlesSurface != null) if (mSubtitlesSurface != null)
mAWindow.setSubtitlesView(mSubtitlesSurface); mAWindow.setSubtitlesView(mSubtitlesSurface);
mAWindow.attachViews(); mAWindow.attachViews(this);
if (mOnLayoutChangeListener == null) { if (mOnLayoutChangeListener == null) {
mOnLayoutChangeListener = new View.OnLayoutChangeListener() { mOnLayoutChangeListener = new View.OnLayoutChangeListener() {
...@@ -269,7 +269,7 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba ...@@ -269,7 +269,7 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override @Override
public void onNewLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) { public void onNewVideoLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
mVideoWidth = width; mVideoWidth = width;
mVideoHeight = height; mVideoHeight = height;
mVideoVisibleWidth = visibleWidth; mVideoVisibleWidth = visibleWidth;
...@@ -282,7 +282,7 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba ...@@ -282,7 +282,7 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba
@Override @Override
public void onSurfacesCreated(IVLCVout vlcVout) { public void onSurfacesCreated(IVLCVout vlcVout) {
if (!mNativeStarted) { if (!mNativeStarted) {
if (!nativeStart(mAWindow.getNativeHandler())) { if (!nativeStart(mAWindow)) {
Toast.makeText(this, "Couldn't start LibVLC", Toast.LENGTH_LONG).show(); Toast.makeText(this, "Couldn't start LibVLC", Toast.LENGTH_LONG).show();
finish(); finish();
return; return;
...@@ -301,6 +301,6 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba ...@@ -301,6 +301,6 @@ public class NativeActivity extends AppCompatActivity implements IVLCVout.Callba
private long mInstance; private long mInstance;
private native boolean nativeCreate(); private native boolean nativeCreate();
private native void nativeDestroy(); private native void nativeDestroy();
private native boolean nativeStart(AWindowNativeHandler aWindowNative); private native boolean nativeStart(AWindow aWindowNative);
private native void nativeStop(); private native void nativeStop();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment