ppoeas
ppoeas

Reputation: 93

LibVLC android seek and forward

I have a problem with seeking in my own android APP. When i forward my rtmp video (MP4 source), then VLC stucks and after 60-120 seconds playing good.

My device is armv7 android TV STB BOX.

        // Create a new media player
        libvlc = LibVLC.getInstance();
        libvlc.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL);
        //libvlc.setSubtitlesEncoding("");
        //libvlc.setAout(LibVLC.VOUT_ANDROID_SURFACE);
        //libvlc.setTimeStretching(false);
        //libvlc.setFrameSkip(true);

        libvlc.setSubtitlesEncoding("");
        libvlc.setTimeStretching(false);
        libvlc.setFrameSkip(true);
        libvlc.setChroma("RV32");
        libvlc.setVerboseMode(true);
        libvlc.setAout(-1);
        libvlc.setDeblocking(4);
        libvlc.setNetworkCaching(0);



        //libvlc.setChroma("RV32");
        //libvlc.setVerboseMode(false);
        //libvlc.setDeblocking(1);
        //libvlc.setNetworkCaching(2500);
        LibVLC.restart(this);
        EventHandler.getInstance().addHandler(mHandler);
        holder.setFormat(PixelFormat.RGBX_8888);
        holder.setKeepScreenOn(true);
        MediaList list = libvlc.getMediaList();
        list.clear();
        list.add(new Media(libvlc, LibVLC.PathToURI(media)), false);
        libvlc.playIndex(0);

On other player such as MXPlayer there is no problem with that. Vitamio works good, but there is a problem with audio sync. Without seeking video on VLC works good, below is my forward and rewind action:

switch (event.getKeyCode()) {

        // next
        case 87:

            s = false;

            if (length > 0L) {
                Long t = time+60000L;
                if (t < length) {
                    //libvlc.clearBuffer();
                    libvlc.setTime(time+60000L);
                    libvlc.play();
                }
            }

            break;
        // prev
        case 88:

            s = false;

            if (length > 0L) {
                Long t = time-60000L;
                if (t > 0) {
                    libvlc.setTime(time-60000L);
                    libvlc.play();
                }
            }

            break;
    }

Upvotes: 4

Views: 3950

Answers (1)

TastyCatFood
TastyCatFood

Reputation: 1772

I could not understand your question but if that's not being able to set the seeker position when MedaiPlayer is not playing, then calling setPosition while playing does the trick:

        if(!isPlaying){
            mp.play();//otherwise not seekable for some silly reason
            mp.setTime((long)pos);
            mp.pause();
        }else{
            mp.setTime((long)pos);
        }

mp is MediaPlayer, of course. Since getLength() has the same issue, it's really annoying iso a good documentation and tutorial!!

Upvotes: 1

Related Questions