mrmaffen / vlc-android-sdk Goto Github PK
View Code? Open in Web Editor NEWVLC Android SDK pushed to Maven Central. Primarily used in project tomahawk-android.
VLC Android SDK pushed to Maven Central. Primarily used in project tomahawk-android.
hello there
i've implemented the library successfully, but the issue is that when i stop the stream, the application freezes and uses a 50% of the cpu and never unfreeze
i use mediaPlayer.stop(); in the main thread
After sdk update from 1.0.4 to 1.0.6 I faced the problem:
android_surface vout display: Could not initialize libandroid.so/libui.so/libgui.so/libsurfaceflinger_client.so!
Debug messages I added:
android_surface vout display: dlopen 'libsurfaceflinger_client.so' result = 0x0
android_surface vout display: dlopen 'libgui.so' result = 0xb6e7d644
android_surface vout display: s_lock = 0x0
android_surface vout display: s_lock2 = 0x0
android_surface vout display: s_unlock = 0xb6b0c081
android_surface vout display: dlopen 'libui.so' result = 0xb6e7d8c4
android_surface vout display: s_lock = 0x0
android_surface vout display: s_lock2 = 0x0
android_surface vout display: s_unlock = 0x0
Help me, please!
this is my vedio url:
http://video.kocla.com/Phonics.Kids.DVD.2_201609280833530524.avi?e=2137310110&token=kEUFey_36xJqHaOhr44fNd8eNUo4a9TLtMJSrqhu:LCcx_VvUkxLbYSPc7GcbRwvPVJY=
vlc takes a long time to load when starting to play and seeking
I tried to compile the vlc lib using your script because it's almost impossible to compie using the instructions in vlc page (https://wiki.videolan.org/AndroidCompile/)
The problem is that the same erros happened.
Can you give some advice about this?
I am using Ubuntu 15
Do I need to downgrade my Ubuntu to 13?
Thanks
These are the errors:
configure.ac:46: installing 'autotools/compile'
configure.ac:23: installing 'autotools/config.guess'
configure.ac:23: installing 'autotools/config.sub'
configure.ac:27: installing 'autotools/install-sh'
configure.ac:27: installing 'autotools/missing'
parallel-tests: installing 'autotools/test-driver'
bin/Makefile.am: installing 'autotools/depcomp'
compat/Makefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined
compat/Makefile.am:1: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
compat/Makefile.am:1: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
compat/Makefile.am:1: If 'LT_INIT' is in 'configure.ac', make sure
compat/Makefile.am:1: its definition is in aclocal's search path.
lib/Makefile.am:31: error: Libtool library used but 'LIBTOOL' is undefined
lib/Makefile.am:31: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
lib/Makefile.am:31: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
lib/Makefile.am:31: If 'LT_INIT' is in 'configure.ac', make sure
lib/Makefile.am:31: its definition is in aclocal's search path.
modules/Makefile.am:20: error: Libtool library used but 'LIBTOOL' is undefined
modules/Makefile.am:20: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
modules/Makefile.am:20: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
modules/Makefile.am:20: If 'LT_INIT' is in 'configure.ac', make sure
modules/Makefile.am:20: its definition is in aclocal's search path.
modules/gui/macosx/Makefile.am:18: error: Libtool library used but 'LIBTOOL' is undefined
modules/gui/macosx/Makefile.am:18: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
modules/gui/macosx/Makefile.am:18: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
modules/gui/macosx/Makefile.am:18: If 'LT_INIT' is in 'configure.ac', make sure
modules/gui/macosx/Makefile.am:18: its definition is in aclocal's search path.
modules/gui/qt/Makefile.am:33: error: Libtool library used but 'LIBTOOL' is undefined
modules/gui/qt/Makefile.am:33: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
modules/gui/qt/Makefile.am:33: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
modules/gui/qt/Makefile.am:33: If 'LT_INIT' is in 'configure.ac', make sure
modules/gui/qt/Makefile.am:33: its definition is in aclocal's search path.
modules/gui/skins2/Makefile.am:6: error: Libtool library used but 'LIBTOOL' is undefined
modules/gui/skins2/Makefile.am:6: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
modules/gui/skins2/Makefile.am:6: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
modules/gui/skins2/Makefile.am:6: If 'LT_INIT' is in 'configure.ac', make sure
modules/gui/skins2/Makefile.am:6: its definition is in aclocal's search path.
modules/hw/mmal/Makefile.am:11: error: Libtool library used but 'LIBTOOL' is undefined
modules/hw/mmal/Makefile.am:11: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
modules/hw/mmal/Makefile.am:11: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
modules/hw/mmal/Makefile.am:11: If 'LT_INIT' is in 'configure.ac', make sure
modules/hw/mmal/Makefile.am:11: its definition is in aclocal's search path.
src/Makefile.am:167: error: Libtool library used but 'LIBTOOL' is undefined
src/Makefile.am:167: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
src/Makefile.am:167: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
src/Makefile.am:167: If 'LT_INIT' is in 'configure.ac', make sure
src/Makefile.am:167: its definition is in aclocal's search path.
autoreconf: automake failed with exit status: 1
vlc: bootstrap failed
:compileVlcArmv7a FAILED
Hello
I try to play rtmp streaming from wowza, delay more than 10 second, Howto disable network cache,?
How to use this library. Im using an older one when i try to include this current version its giving me error. Please give me sample code link. I am using 1.0.3
Thanks.
the vlc not show "buffering",i want the "buffering" state,how to do,thanks in advance!
Hey,
could you add armeabi and x86 to your maven repo? Id like to use your build in productive mode but with only v7a, it would exclude too many people.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/videolan/libvlc/EventHandler;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:app:transformClassesWithDexForDebug FAILED
I'm new to the vlc, i don't konw how to use,where to get the android api. thanks
Hi,
I know there is no VLC support here, but just in case... either its a simple thing, or someone else knows the answer.
So I am getting these errors when I try to load an URI that is not woring for some reason.
E/VLC: [7126d274] core input: Your input can't be opened E/VLC: [7126d274] core input: VLC is unable to open the MRL ...
And I really would like to handle these exceptions but I cannot find a callback. The URIs are from a database so I cannot know in advance.
Thanks in advance if you know the answer and can take a little time to respond!
Greg
Build libVlc version wiht anabled sout, it will allow to use libVlc for video recording and save it to file
可以实现视频截图吗?
Hello,
when i try the sdk with my nexus 6p i get following error:
Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/packagename/base.apk"],nativeLibraryDirectories=[/data/app/packagename-1/lib/arm64, /data/app/packagename-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libvlcjni.so"
I am developing the android app that streams the audio and uses RTMP. I added libvlc .aar file to my project but the audio isn't played. (My server is Wowza). The link example "rtmp://178.132.203.158:1935/music/definst/mp3:a33/yb5/gsa/a33yb5gsa370.mp3?wowzartmpstart=1792&wowzartmpduration=20000"
I am using your built SDK for android application. Unfortunately I am receiving this error while running MediaPlayer.play()
:
W/libOpenSLES(23077): class OutputMix interface 0 requested but unavailable MPH=43
The audio doesn't play at all and there is also now volume. Is there any workaround to this please?
How to achieve group video calling in android through VLC by RTMP or RTSP Protocol.
I've been working on an Android application that shows live streaming video via RTSP. Assuming I have a well-functioning RTSP server that passes h264 packets, and to view the stream we should connect to rtsp://192.168.42.1/live, old VLC player works fine, but this version cannot view the live stream.
Code like this:
ArrayList<String> options = new ArrayList<String>();
options.add("--aout=opensles");
options.add("--audio-time-stretch"); // time stretching
options.add("-vvv"); // verbosity
//options.add
libvlc = new LibVLC(options);
holder.setKeepScreenOn(true);
// Create media player
mMediaPlayer = new MediaPlayer(libvlc);
mMediaPlayer.setEventListener(mPlayerListener);
// Set up video output
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.setVideoView(mSurface);
vout.addCallback(this);
vout.attachViews();
//Media m = new Media(libvlc, media);
Media mm = new Media(libvlc,Uri.parse(mVideoPath));
mMediaPlayer.setMedia(mm);
mMediaPlayer.play();
Thank you for your library.
I'm still using the old version "de.mrmaffen:vlc-android-sdk:1.0.3", and I'm going to place the app on Google Play for the alpha test.
But I had a problem, as the developer console does not accept APK with the comment "Failed to recognize the file", and when I turned off the dependence application housed.
Do I need to include some kind of permission to use the library for publication?
How to use embedded VLC player for live Rtsp and RMTP streaming in my application ?
So what are the steps to achieve this?
I installed the dependency link and wrote an example. If it use the standard class MediaPlayer, the local video playing. And if you use org.videolan.libvlc.media.MediaPlayer, it does not show any local or what the link.
Please tell me what I did wrong?
Hi dear, I want to know when your compile the vlc, which the gnutls version in use ?The vulnerability was addressed in GnuTLS 3.1.25, GnuTLS 3.2.15 and GnuTLS 3.3.4
thx!
Hi,
Thanks video is playing fine. But I have one more issue I am not able to capture snapshot of current frame. their is one method getThumbnail but its returning me as null.
snapshotBytes = libvlc.getThumbnail(mediaUrl, 300, 300);
How to get this please help!!
Can you give some development steps for us , thank you very much
Hi, is there any documentation about the SDK ? I would like to play some video's from URL and I couldn't find anything.
Hello,
Im trying to set initial volume with no sucess. If i use setVolume after play is not working, setVolume after some events like vout, playing is not working too and the option --volume= is not working also.
Can you help-me ?
Hi,
I use compile 'de.mrmaffen:vlc-android-sdk:3.0.0' then my app has 30MB in size,
When i update to compile 'de.mrmaffen:vlc-android-sdk:1.9.8', the app get 60MB in size.
big size it not good to upload to Google Play.
Please help.
As new user of the sdk, it is almost impossible to understand how to use it even after several hours reading the source code (which should not be necessary).
Even some quick examples would help a lot.
it's ok now
there is an error in the assembly 1.9.8!
When using the "compile 'de.mrmaffen: vlc-android-sdk: 1.9.8' '" there was an error on some rtmp Stream in flv format, which reads: "W / VLC: [573d7174] avcodec decoder: can not decode one frame ( 9045 bytes) "and the video is only green, broken picture.
I had to return to "compile 'de.mrmaffen: vlc-android-sdk: 1.9.0'" and the problem is gone!
I hope it will help improve the next assembly.
Realse version will remove assert. As the unknown networking status, it's important in product environment.
I'm using vlc sdk version 3.0.0 on real arm 4.4 device
dependency from build.gradle
compile 'de.mrmaffen:vlc-android-sdk:3.0.0'
Here's error from logcat:
01-18 09:31:35.020 11454-11454/? E/AndroidRuntime:
FATAL EXCEPTION: main
Process: com.project, PID: 11454
java.lang.NoSuchMethodError: no method with name='dispatchEventFromNative' signature='(IJJ)V' in class Lorg/videolan/libvlc/VLCObject;
at java.lang.Runtime.nativeLoad(Native Method)
at java.lang.Runtime.doLoad(Runtime.java:428)
at java.lang.Runtime.loadLibrary(Runtime.java:369)
at java.lang.System.loadLibrary(System.java:526)
at org.videolan.libvlc.LibVLC.<clinit>(LibVLC.java:192)
at com.project.VideoActivity.createPlayer(VideoActivity.java:176)
at com.project.VideoActivity.onResume(VideoActivity.java:93)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1197)
at android.app.Activity.performResume(Activity.java:5422)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2989)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Code in VideoActivity is almost the same as in example project.
On 5.0+ works fine.
05-26 15:39:32.788 2782-2782/org.snowden.vlcplayer I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@25eda9ca time:115941587
05-26 15:39:36.228 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libcompat.7.so: unused DT entry: type 0x6ffffffe arg 0x370
05-26 15:39:36.228 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libcompat.7.so: unused DT entry: type 0x6fffffff arg 0x1
05-26 15:39:36.228 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libanw.21.so: unused DT entry: type 0x6ffffffe arg 0x818
05-26 15:39:36.228 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libanw.21.so: unused DT entry: type 0x6fffffff arg 0x1
05-26 15:39:36.238 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libvlc.so: unused DT entry: type 0x6ffffffe arg 0x1898c8
05-26 15:39:36.238 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libvlc.so: unused DT entry: type 0x6fffffff arg 0x3
05-26 15:39:36.268 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libvlcjni.so: unused DT entry: type 0x6ffffffe arg 0x4940
05-26 15:39:36.268 2782-2782/org.snowden.vlcplayer W/linker: /data/app/org.snowden.vlcplayer-1/lib/arm64/libvlcjni.so: unused DT entry: type 0x6fffffff arg 0x1
Hello, please add buffering event like this
https://code.videolan.org/videolan/vlc-android/commit/1c4b6c51cb33dc884f78e7c7bb4b9e9d8eff18fc
Hello!
How do I use the version 1.9.8 if I need to run on the device armeabi (my apk has a min-sdk 9), and this assembly comprises armeabi-v7a?
Hey there,
I noticed this library has no license. Can I assume this uses the same license as LibVLC (LGPL) or do you want to license your code differently?
Hey there.
I know I really should be asking this question at VLC Forums or IRC, but my IP got banned at the Forums (no idea why) and no one really helps on the IRC channel.
I compiled VLC, got the .so files and then imported it as an Existing Project into my Gradle. All this worked fine.
But problem 1: the .so files don't get copied to /data/data//lib/ when I run gradle build. Do I have to make any changes to build.gradle?
Problem 2: I tried manually copying libvlcjni.so to /data/data//lib/. But still system.loadLibrary() doesn't work.
It says
21221 dalvikvm E dlopen("/data/data/com.vibin.billy.debug/lib/libvlcjni.so") failed: dlopen failed: library "/data/data/com.vibin.billy.debug/lib/libvlcjni.so" not found
21221 VLC/LibVLC E Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/data/com.vibin.billy.debug/lib/libvlcjni.so" not found
Thanks a lot!
I added a dependency compile "de.mrmaffen:vlc-android-sdk:3.0.0".
I wrote a class:
`
public class MainActivity extends Activity implements IVLCVout.Callback, LibVLC.HardwareAccelerationError {
public final static String TAG = "LibVLCAndroidSample/VideoActivity";
private String mFilePath;
// display surface
private SurfaceView mSurface;
private SurfaceHolder holder;
// media player
private LibVLC libvlc;
private MediaPlayer mMediaPlayer = null;
private int mVideoWidth;
private int mVideoHeight;
private final static int VideoSizeChanged = -1;
private String urlVideo = "rtmp://myserver.com:1935/rtmp/video1";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Receive path to play from intent
mFilePath = urlVideo;
Log.d(TAG, "Playing back " + mFilePath);
mSurface = (SurfaceView) findViewById(R.id.surfaceview);
holder = mSurface.getHolder();
//holder.addCallback(this);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setSize(mVideoWidth, mVideoHeight);
}
@Override
protected void onResume() {
super.onResume();
createPlayer(mFilePath);
}
@Override
protected void onPause() {
super.onPause();
releasePlayer();
}
@Override
protected void onDestroy() {
super.onDestroy();
releasePlayer();
}
/*************
* Surface
*************/
private void setSize(int width, int height) {
mVideoWidth = width;
mVideoHeight = height;
if (mVideoWidth * mVideoHeight <= 1)
return;
if(holder == null || mSurface == null)
return;
// get screen size
int w = getWindow().getDecorView().getWidth();
int h = getWindow().getDecorView().getHeight();
// getWindow().getDecorView() doesn't always take orientation into
// account, we have to correct the values
boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
if (w > h && isPortrait || w < h && !isPortrait) {
int i = w;
w = h;
h = i;
}
float videoAR = (float) mVideoWidth / (float) mVideoHeight;
float screenAR = (float) w / (float) h;
if (screenAR < videoAR)
h = (int) (w / videoAR);
else
w = (int) (h * videoAR);
// force surface buffer size
holder.setFixedSize(mVideoWidth, mVideoHeight);
// set display size
ViewGroup.LayoutParams lp = mSurface.getLayoutParams();
lp.width = w;
lp.height = h;
mSurface.setLayoutParams(lp);
mSurface.invalidate();
}
/*************
* Player
*************/
private void createPlayer(String media) {
releasePlayer();
try {
if (media.length() > 0) {
Toast toast = Toast.makeText(this, media, Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
0);
toast.show();
}
// Create LibVLC
// TODO: make this more robust, and sync with audio demo
ArrayList<String> options = new ArrayList<String>();
//options.add("--subsdec-encoding <encoding>");
options.add("--aout=opensles");
options.add("--audio-time-stretch"); // time stretching
options.add("-vvv"); // verbosity
libvlc = new LibVLC(options);
libvlc.setOnHardwareAccelerationError(this);
holder.setKeepScreenOn(true);
// Create media player
mMediaPlayer = new MediaPlayer(libvlc);
mMediaPlayer.setEventListener(mPlayerListener);
// Set up video output
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.setVideoView(mSurface);
//vout.setSubtitlesView(mSurfaceSubtitles);
vout.addCallback(this);
vout.attachViews();
Media m = new Media(libvlc, media);
mMediaPlayer.setMedia(m);
mMediaPlayer.play();
} catch (Exception e) {
Toast.makeText(this, "Error creating player!", Toast.LENGTH_LONG).show();
}
}
private void releasePlayer() {
if (libvlc == null)
return;
mMediaPlayer.stop();
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.removeCallback(this);
vout.detachViews();
holder = null;
libvlc.release();
libvlc = null;
mVideoWidth = 0;
mVideoHeight = 0;
}
private static class MyPlayerListener implements MediaPlayer.EventListener {
private WeakReference<MainActivity> mOwner;
public MyPlayerListener(MainActivity owner) {
mOwner = new WeakReference<MainActivity>(owner);
}
@Override
public void onEvent(MediaPlayer.Event event) {
MainActivity player = mOwner.get();
switch(event.type) {
case MediaPlayer.Event.EndReached:
Log.d(TAG, "MediaPlayerEndReached");
player.releasePlayer();
break;
case MediaPlayer.Event.Playing:
case MediaPlayer.Event.Paused:
case MediaPlayer.Event.Stopped:
default:
break;
}
}
}
/*************
* Events
*************/
private MediaPlayer.EventListener mPlayerListener = new MyPlayerListener(this);
@Override
public void onNewLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
if (width * height == 0)
return;
// store video size
mVideoWidth = width;
mVideoHeight = height;
setSize(mVideoWidth, mVideoHeight);
}
@Override
public void onSurfacesCreated(IVLCVout vlcVout) {
}
@Override
public void onSurfacesDestroyed(IVLCVout vlcVout) {
}
@Override
public void eventHardwareAccelerationError() {
Log.e(TAG, "Error with hardware acceleration");
this.releasePlayer();
Toast.makeText(this, "Error with hardware acceleration", Toast.LENGTH_LONG).show();
}
}
`
I receive an error:
core access: VLC could not open the file "//rtmp://myserver.com:1935/rtmp/video1" (No such file or directory).
why the link was a file?
Please add method for play url stream and add the play from url and add event to buffering please/ thanks
Error play videoView. Help me please!!!
` <org.videolan.libvlc.media.VideoView
android:id="@+id/video_view"
android:layout_width="370dp"
android:layout_height="360dp"
android:layout_marginBottom="37dp"> </org.videolan.libvlc.media.VideoView>
`
` public class MainActivity extends AppCompatActivity implements IVLCVout.Callback {
private static final String TAG = MainActivity.class.getSimpleName();
private String mVideoUrl;
// media player
private LibVLC libvlc;
private VideoView videoView;
private SurfaceHolder holder;
private MediaPlayer mMediaPlayer = null;
private int mVideoWidth;
private int mVideoHeight;
private final static int VideoSizeChanged = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
videoView = (VideoView) findViewById(R.id.video_view);
mVideoUrl = "http://171.25.232.14:8081/nvr/hls/AyTbyjr42CKLwLXT7FBsyM9SVf8Q29/1474600200/300/index.m3u8";
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setSize(mVideoWidth, mVideoHeight);
}
@Override
protected void onResume() {
super.onResume();
createMediaPlayer();
}
@Override
protected void onPause() {
super.onPause();
releasePlayer();
}
@Override
protected void onDestroy() {
super.onDestroy();
releasePlayer();
}
private void setSize(int width, int height) {
mVideoWidth = width;
mVideoHeight = height;
if (mVideoWidth * mVideoHeight <= 1)
return;
// get screen size
int w = getWindow().getDecorView().getWidth();
int h = getWindow().getDecorView().getHeight();
// getWindow().getDecorView() doesn't always take orientation into
// account, we have to correct the values
boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
if (w > h && isPortrait || w < h && !isPortrait) {
int i = w;
w = h;
h = i;
}
float videoAR = (float) mVideoWidth / (float) mVideoHeight;
float screenAR = (float) w / (float) h;
if (screenAR < videoAR)
h = (int) (w / videoAR);
else
w = (int) (h * videoAR);
// force surface buffer size
videoView.getHolder().setFixedSize(mVideoWidth, mVideoHeight);
// set display size
ViewGroup.LayoutParams lp = videoView.getLayoutParams();
lp.width = w;
lp.height = h;
videoView.setLayoutParams(lp);
videoView.invalidate();
}
private void createMediaPlayer() {
releasePlayer();
try {
// Create LibVLC
ArrayList<String> options = new ArrayList<String>();
//options.add("--subsdec-encoding <encoding>");
options.add("--aout=opensles");
options.add("--audio-time-stretch"); // time stretching
options.add("-vvv"); // verbosity
libvlc = new LibVLC(options);
mMediaPlayer = new MediaPlayer(libvlc);
mMediaPlayer.setEventListener(mPlayerListener);
videoView.setVideoPath(mVideoUrl);
videoView.setVideoURI(Uri.parse(mVideoUrl));
videoView.setMediaController(new MediaController(this));
videoView.start();
} catch (Exception e) {
e.printStackTrace();
}
}
// TODO: handle this cleaner
private void releasePlayer() {
if (libvlc == null)
return;
mMediaPlayer.stop();
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.removeCallback(this);
vout.detachViews();
videoView = null;
libvlc.release();
libvlc = null;
mVideoWidth = 0;
mVideoHeight = 0;
}
private MediaPlayer.EventListener mPlayerListener = new MyPlayerListener(this);
@Override
public void onNewLayout(IVLCVout vout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
if (width * height == 0)
return;
// store video size
mVideoWidth = width;
mVideoHeight = height;
setSize(mVideoWidth, mVideoHeight);
}
@Override
public void onSurfacesCreated(IVLCVout vout) {
}
@Override
public void onSurfacesDestroyed(IVLCVout vout) {
}
@Override
public void onHardwareAccelerationError(IVLCVout vlcVout) {
}
private static class MyPlayerListener implements MediaPlayer.EventListener {
private WeakReference mOwner;
public MyPlayerListener(MainActivity owner) {
mOwner = new WeakReference<MainActivity>(owner);
}
@Override
public void onEvent(MediaPlayer.Event event) {
MainActivity player = (MainActivity) mOwner.get();
switch (event.type) {
case MediaPlayer.Event.EndReached:
Log.d(TAG, "MediaPlayerEndReached");
player.releasePlayer();
break;
case MediaPlayer.Event.Playing:
case MediaPlayer.Event.Paused:
case MediaPlayer.Event.Stopped:
default:
break;
}
}
}
`
FATAL EXCEPTION: main Process: com.example.bogdanovkp.myapplication, PID: 23708 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bogdanovkp.myapplication/com.example.bogdanovkp.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class org.videolan.libvlc.media.VideoView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class org.videolan.libvlc.media.VideoView at android.view.LayoutInflater.createView(LayoutInflater.java:620) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) at com.example.bogdanovkp.myapplication.MainActivity.onCreate(MainActivity.java:42) at android.app.Activity.performCreate(Activity.java:5312) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:594) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) at com.example.bogdanovkp.myapplication.MainActivity.onCreate(MainActivity.java:42) at android.app.Activity.performCreate(Activity.java:5312) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoSuchMethodError: android.view.SurfaceView.<init> at org.videolan.libvlc.media.VideoView.<init>(VideoView.java:70) at org.videolan.libvlc.media.VideoView.<init>(VideoView.java:65) at org.videolan.libvlc.media.VideoView.<init>(VideoView.java:61) at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:594) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) at com.example.bogdanovkp.myapplication.MainActivity.onCreate(MainActivity.java:42) at android.app.Activity.performCreate(Activity.java:5312) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885) at dalvik.system.NativeStart.main(Native Method)
I should need to add something that If i am using ProGuard
Hey,
I would like to exclude architectures for x86 and x86_64 which I don't need and it's just blowing up my APK.
Is there any way when using Gradle to do this using an exclude statement?
Thanks,
Ralf
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.