tcking / GiraffePlayer2

out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
Apache License 2.0
377 stars 110 forks source link

Get current position of Seekbar #128

Open smaharjan974 opened 6 years ago

smaharjan974 commented 6 years ago

Can you tell me how I can I get the current position of seek bar and play the video from where I want? I used the code to get current position and video duration. I got the video duration but can't get the current position of the video. MediaPlayer mp = MediaPlayer.create(this, Uri.parse(decryptedFile));

    mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            int duration=mp.getDuration()/1000;
            int hours = duration / 3600;
            int minutes = (duration / 60) - (hours * 60);
            int seconds = duration - (hours * 3600) - (minutes * 60) ;
            Log.d("asdf", "onPrepared: "+seconds+"  "+minutes+" "+duration);

            int currentPosition = mp.getCurrentPosition()/1000;
            Log.d("currentpostion", "onUserLeaveHint: "+currentPosition);
            mp.release();
        }
    });