mrmaffen / vlc-android-sdk

VLC Android SDK pushed to Maven Central. Primarily used in project tomahawk-android.
792 stars 244 forks source link

about play file in cell phone #69

Open PeterChuang opened 7 years ago

PeterChuang commented 7 years ago

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");
Allier commented 7 years ago

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)

PeterChuang commented 7 years ago

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

DheerubhaiBansal commented 7 years ago

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."