Search in sources :

Example 1 with VideoProgressTarget

use of com.yiw.circledemo.widgets.videolist.target.VideoProgressTarget in project CircleDemo by Naoki2015.

the class CircleVideoView method init.

private void init() {
    inflate(getContext(), R.layout.layout_video, this);
    videoPlayer = (TextureVideoView) findViewById(R.id.video_player);
    videoFrame = (ImageView) findViewById(R.id.iv_video_frame);
    videoProgress = (CircularProgressBar) findViewById(R.id.video_progress);
    videoButton = (ImageView) findViewById(R.id.iv_video_play);
    videoTarget = new VideoLoadTarget(this);
    progressTarget = new VideoProgressTarget(videoTarget, videoProgress);
    videoPlayer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (videoPlayer.isPlaying()) {
                videoPlayer.stop();
            }
        }
    });
    videoButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (TextUtils.isEmpty(videoUrl)) {
                Toast.makeText(getContext(), "video url is empty...", Toast.LENGTH_LONG).show();
                return;
            }
            // load video file
            videoState = STATE_ACTIVED;
            progressTarget.start();
            Glide.with(getContext()).using(VideoListGlideModule.getOkHttpUrlLoader(), InputStream.class).load(new GlideUrl(videoUrl)).as(File.class).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(progressTarget);
            videoButton.setVisibility(View.INVISIBLE);
            if (onPlayClickListener != null) {
                onPlayClickListener.onPlayClick(postion);
            }
        }
    });
}
Also used : VideoProgressTarget(com.yiw.circledemo.widgets.videolist.target.VideoProgressTarget) InputStream(java.io.InputStream) VideoLoadTarget(com.yiw.circledemo.widgets.videolist.target.VideoLoadTarget) GlideUrl(com.bumptech.glide.load.model.GlideUrl) ImageView(android.widget.ImageView) VideoLoadMvpView(com.yiw.circledemo.widgets.videolist.model.VideoLoadMvpView) TextureVideoView(com.yiw.circledemo.widgets.videolist.widget.TextureVideoView) View(android.view.View) File(java.io.File)

Aggregations

View (android.view.View)1 ImageView (android.widget.ImageView)1 GlideUrl (com.bumptech.glide.load.model.GlideUrl)1 VideoLoadMvpView (com.yiw.circledemo.widgets.videolist.model.VideoLoadMvpView)1 VideoLoadTarget (com.yiw.circledemo.widgets.videolist.target.VideoLoadTarget)1 VideoProgressTarget (com.yiw.circledemo.widgets.videolist.target.VideoProgressTarget)1 TextureVideoView (com.yiw.circledemo.widgets.videolist.widget.TextureVideoView)1 File (java.io.File)1 InputStream (java.io.InputStream)1