vlc-android-sdk icon indicating copy to clipboard operation
vlc-android-sdk copied to clipboard

about play file in cell phone

Open PeterChuang opened this issue 7 years ago • 3 comments

I am wondering if I can play media file via playMRL()? for example try { mLibVLC = new LibVLC(); mLibVLC.setAout(mLibVLC.AOUT_AUDIOTRACK); mLibVLC.setVout(mLibVLC.VOUT_ANDROID_SURFACE); mLibVLC.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL);

        mLibVLC.init(getApplicationContext());
    } catch (LibVlcException e){
        Log.e(TAG, e.toString());
    }

    mSurface = mSurfaceHolder.getSurface();

    mLibVLC.attachSurface(mSurface, VideoVLCActivity.this);
    mLibVLC.playMRL("/storage/emulated/0/Download/xxx.mp4");

PeterChuang avatar Mar 09 '17 08:03 PeterChuang

As far as I know you can't do that anymore in new versions of LibVLC. There are no methods that are media-related in VLC instance anymore, you need to use MediaPlayer to play media. You can wrap MRL with Media and then play: Java mediaPlayer.setMedia(new Media(VLCInstance.get(), mrl)); media.release(); mediaPlayer.play()

See libvlc sources for reference: https://code.videolan.org/videolan/vlc-android/blob/2.1.1/vlc-android/src/org/videolan/vlc/PlaybackService.java (see playIndex method for example)

Allier avatar Mar 09 '17 13:03 Allier

thanks for the response. I've tried the following code and it works MediaList list = libvlc.getMediaList(); list.clear(); list.add(new Media(mLibVLC, LibVLC.PathToURI("/storage/emulated/0/Download/xxx.mp4")), false); mLibVLC.playIndex(0);

PeterChuang avatar Mar 13 '17 05:03 PeterChuang

It is working only if target sdk 22 in build.gradle, when target sdk increase to 25 then a dialog appear "Detected problem with app native libraries (please consult log detail): libvlcjni.so: text relocations."

DheerubhaiBansal avatar Mar 16 '17 09:03 DheerubhaiBansal