Commit f009d63609797e9048d29c1d6ac6ea02093cc147
1 parent
771875a1
视频预览修改
Showing
2 changed files
with
20 additions
and
15 deletions
core/imageload/src/main/java/com/cnlive/core/imagepreview/ImageDrawee.java
| ... | ... | @@ -13,12 +13,8 @@ import com.bumptech.glide.request.target.Target; |
| 13 | 13 | import com.cnlive.core.imageload.R; |
| 14 | 14 | import com.cnlive.core.imagepreview.indexui.ProgressUI; |
| 15 | 15 | import com.github.chrisbanes.photoview.PhotoView; |
| 16 | -import com.libs.video.util.cache.PreloadManager; | |
| 17 | -import com.libs.video.video.exoplayer.component.DefaultErrorView; | |
| 18 | -import com.libs.video.video.exoplayer.component.DefaultYoukuPrepareView; | |
| 19 | -import com.libs.video.video.exoplayer.controller.StandardVideoController; | |
| 20 | -import com.libs.video.video.exoplayer.controller.TikTokController; | |
| 21 | 16 | import com.libs.video.video.exoplayer.play.CNVideoView; |
| 17 | +import com.libs.video.video.exoplayer.util.PlayerUtils; | |
| 22 | 18 | |
| 23 | 19 | import androidx.annotation.NonNull; |
| 24 | 20 | import androidx.annotation.Nullable; |
| ... | ... | @@ -28,9 +24,10 @@ import androidx.annotation.Nullable; |
| 28 | 24 | * on 2020/1/20 |
| 29 | 25 | */ |
| 30 | 26 | public class ImageDrawee extends FrameLayout { |
| 31 | - private PhotoView imageView; | |
| 27 | + private PhotoView imageView = null; | |
| 32 | 28 | private ProgressUI progressUI; |
| 33 | 29 | private ViewData viewData; |
| 30 | + private CNVideoView videoView; | |
| 34 | 31 | |
| 35 | 32 | public ImageDrawee(@NonNull Context context,ViewData viewData,CNVideoView videoView) { |
| 36 | 33 | super(context); |
| ... | ... | @@ -39,12 +36,12 @@ public class ImageDrawee extends FrameLayout { |
| 39 | 36 | } |
| 40 | 37 | |
| 41 | 38 | private void init(CNVideoView videoView) { |
| 42 | - // 添加 imageView | |
| 43 | 39 | if(viewData.getType() == 1){ |
| 44 | 40 | imageView = new PhotoView(getContext()); |
| 45 | 41 | addView(imageView); |
| 46 | 42 | }else { |
| 47 | - removeAllViews(); | |
| 43 | + PlayerUtils.removeViewFormParent(videoView); | |
| 44 | + this.videoView = videoView; | |
| 48 | 45 | addView(videoView); |
| 49 | 46 | } |
| 50 | 47 | } |
| ... | ... | @@ -109,13 +106,21 @@ public class ImageDrawee extends FrameLayout { |
| 109 | 106 | return imageView; |
| 110 | 107 | } |
| 111 | 108 | |
| 112 | - public void setImage(Object obj, LoadImage.LoadCallback callback) { | |
| 113 | - if (obj == null) { | |
| 109 | + public CNVideoView getVideoView() { | |
| 110 | + return videoView; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setImage(ViewData data, LoadImage.LoadCallback callback) { | |
| 114 | + if (data == null) { | |
| 114 | 115 | return; |
| 115 | 116 | } |
| 116 | - if(viewData.getType() == 1){ | |
| 117 | + if(videoView != null){ | |
| 118 | + videoView.release(); | |
| 119 | +// PlayerUtils.removeViewFormParent(videoView); | |
| 120 | + } | |
| 121 | + if(viewData.getType() == 1 && imageView != null){ | |
| 117 | 122 | Glide.with(getContext()) |
| 118 | - .load(obj) | |
| 123 | + .load(data.getImageSrc()) | |
| 119 | 124 | .listener(new RequestListener<Drawable>() { |
| 120 | 125 | @Override |
| 121 | 126 | public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { |
| ... | ... | @@ -131,10 +136,10 @@ public class ImageDrawee extends FrameLayout { |
| 131 | 136 | }) |
| 132 | 137 | .error(R.drawable.preview_zwtp) |
| 133 | 138 | .into(imageView); |
| 134 | - }else if(viewData.getType() == 2){ | |
| 135 | - | |
| 139 | + }else if(viewData.getType() == 2 && videoView != null){ | |
| 140 | + videoView.setUrl("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); | |
| 141 | + videoView.start(); | |
| 136 | 142 | } |
| 137 | - | |
| 138 | 143 | } |
| 139 | 144 | |
| 140 | 145 | public float getScale() { | ... | ... |
core/imageload/src/main/res/drawable/changtu.jpeg
0 → 100644
450 KB