android中的流式视频文件的自定义搜索栏

时间:2009-12-03 12:45:23

标签: android video streaming

如何在Android中为流媒体视频文件显示自定义搜索栏?

2 个答案:

答案 0 :(得分:8)

您好,您可以使用以下代码为您的视频视图实现自定义搜索栏,

 videoView.setOnPreparedListener(new OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mp) {

                seekBar.setMax(videoView.getDuration());
                seekBar.postDelayed(onEverySecond, 1000);
            }
        });

    private Runnable onEverySecond=new Runnable() {

        @Override
        public void run() {

            if(seekBar != null) {
                seekBar.setProgress(videoView.getCurrentPosition());
            }

            if(videoView.isPlaying()) {
                seekBar.postDelayed(onEverySecond, 1000);
            }

        }
    };

seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromUser) {

            if(fromUser) {
                // this is when actually seekbar has been seeked to a new position
                videoView.seekTo(progress);
            }
        }
    });

答案 1 :(得分:0)

只需使用SeekBar课程即可。然后,您可以使用setProgress()setSecondaryProgress()

如果您想更改样式,请参阅此问题:How to customize the look of a SeekBar in Android?