mrmaffen / vlc-android-sdk

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

Exampel Simple Player #66

Open azzahrah opened 7 years ago

azzahrah commented 7 years ago

hello

Any one can share howto use this sdk for simple player, add media to media list, and play media by index

TIA

SaundersB commented 7 years ago

See here: https://bitbucket.org/edwardcw/libvlc-android-sample

azzahrah commented 7 years ago

Thank you..., but i try, sample code by edwardcw different version with this version

KnIfER commented 7 years ago

well,following the example above I can easily play a .mp3 sound file,but I have no idea how to display a video file.can u give me more hints?

KnIfER commented 7 years ago

use such code below in onCreate method just crash the app,and throw"io....null pointer error.....try to call .getDir() on ....." code:MediaPlayer mMediaplayer = new org.videolan.libvlc.media.MediaPlayer();

it seems that I can only use this: LibVLC mLibVLC = new LibVLC(this); mMediaPlayer= new org.videolan.libvlc.MediaPlayer(mLibVLC);

KnIfER commented 7 years ago

hahaha I figured it out,referring to issue "Update surfaceview when replaying video #78". do like this:(just partial)

public class VlcMainActivity extends Activity implements SurfaceHolder.Callback, Callback { onCreate() {

    mMediaPlayer = new MediaPlayer(mLibVLC);
    mMediaPlayer.getVLCVout().setVideoView(mSurfaceView);
    mMediaPlayer.getVLCVout().addCallback(this);
    mMediaPlayer.getVLCVout().attachViews();
     playMediaAtPath("/sdcard/myFolder/abc.mp4");

}

@Override
public void surfaceCreated(SurfaceHolder holder) {
    if (mMediaPlayer != null) {
        mSurfaceHolder = holder;
        mMediaPlayer.getVLCVout().detachViews();
        mMediaPlayer.getVLCVout().setVideoSurface(holder.getSurface(), holder);
        mMediaPlayer.getVLCVout().attachViews();
        //mMediaPlayer.getVLCVout().setVideoSurface(holder.getSurface(), holder);
    }
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    mSurfaceHolder = holder;
    if (mMediaPlayer != null) {
        //mMediaPlayer.attachSurface(holder.getSurface(), this);//, width, height
        mMediaPlayer.getVLCVout().detachViews();
        mMediaPlayer.getVLCVout().setVideoSurface(holder.getSurface(), holder);
        mMediaPlayer.getVLCVout().attachViews();
    }
    if (width > 0) {
        mVideoHeight = height;
        mVideoWidth = width;
    }
}

}

supirman commented 7 years ago

@KnIfER Do you have repository of working sample?