I am playing a video from url and I want to disable the seekbar tracking of the video. How can it be done.
This my code:
videoUrl = "http://download.itcuties.com/teaser/itcuties-teaser-480.mp4";
videoview.setVideoPath(videoUrl);
mediaController = new MediaController(this, false);
int topContainerId = getResources().getIdentifier("mediacontroller_progress", "id", "android");
seekBarVideo=(SeekBar)mediaController.findViewById(topContainerId);
seekBarVideo.setEnabled(false);
mediaController.setAnchorView(videoview);
videoview.setMediaController(mediaController);
The app crashes: seekBarVideo.setEnabled(false);
java.lang.NullPointerException
at com.vfirst.offers.VideoBufferActivity.onClick(VideoBufferActivity.java:93)
at android.view.View.performClick(View.java:4575)
at android.view.View$PerformClick.run(View.java:18578)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5127)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Was able to solve with help of this
Need to get seekbar in onPreparedListener of videoview
videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
int topContainerId = getResources().getIdentifier("mediacontroller_progress", "id", "android");
seekBarVideo = (SeekBar) mediaController.findViewById(topContainerId);
seekBarVideo.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
seekBar.setEnabled(false);
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
seekBar.setEnabled(false);
}
});
}
});