104 193
        }
105 194
106 195
        @Override
@ -113,7 +202,11 @@ public class ChatContentListActivity extends AppCompatActivity {
113 202
    public static class ChatContentFragment extends Fragment {
114 203
        private static final String ARG_INDEX = "index";
115 204
        private static final String ARG_FROM = "from";
116
        private StandardGSYVideoPlayer videoPlayer;
205
        private VideoPlayer videoPlayer;
206
        private ImageView videoIcon;
207
        private ProgressBar progressBar;
208
        private ChatRecommendBean bean;
209
        private ImageView playIcon;
117 210
118 211
        public static ChatContentFragment newInstance(int index, String from) {
119 212
            ChatContentFragment fragment = new ChatContentFragment();
@ -133,7 +226,6 @@ public class ChatContentListActivity extends AppCompatActivity {
133 226
            View rootView = null;
134 227
            int index = getArguments().getInt(ARG_INDEX, 0);
135 228
            String from = getArguments().getString(ARG_FROM, "");
136
            ChatRecommendBean bean = null;
137 229
            if (from.equals(FROM_CHAT_HOME)) {
138 230
                bean = ChatBeanLab.get(getContext()).beansExceptTopic().get(index);
139 231
            }
@ -148,21 +240,141 @@ public class ChatContentListActivity extends AppCompatActivity {
148 240
                }
149 241
            }
150 242
151
152 243
            return rootView;
153 244
        }
154 245
155 246
        private void initVideoView(View rootView, ChatRecommendBean bean) {
156 247
            videoPlayer = rootView.findViewById(R.id.videoPlayer);
157 248
            videoPlayer.setUp(bean.videoUrl, true, "");
158
            videoPlayer.getTitleTextView().setVisibility(View.GONE);    // 不显示标题
159
            videoPlayer.getBackButton().setVisibility(View.GONE);       // 不显示返回箭头
160
            videoPlayer.setBackgroundColor(Color.parseColor("#ff0000"));
161
//            videoPlayer.setIsTouchWiget(false);                       // 是否可以滑动调整
162
            videoPlayer.setNeedLockFull(true);
249
            videoIcon = rootView.findViewById(R.id.videoIcon);
250
            progressBar = rootView.findViewById(R.id.progressBar);
251
            playIcon = rootView.findViewById(R.id.playIcon);
252
            ImageView testImg = rootView.findViewById(R.id.testImg);
253
254
255
            if (bean.coverImgH != 0 && bean.coverImgW != 0 && bean.coverImgW > bean.coverImgH) {
256
                int navHeight = DensityUtil.dip2px(getContext(), 44);
257
                ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) videoPlayer.getLayoutParams();
258
                int videoRealHeight = (int) ((float) screenWidth / bean.coverImgW * bean.coverImgH);
259
                params.height = videoRealHeight;
260
                params.bottomToBottom = -1;
261
                params.topMargin = statusBarHeight + navHeight + DensityUtil.dip2px(getContext(), 60);
262
263
//                if (bean.topicId == 0) {
264
//                    int space = screenHeight - DensityUtil.dip2px(getContext(), 152) - statusBarHeight - navHeight;
265
//                    if (space > videoRealHeight) {
266
//                        params.topMargin = statusBarHeight + navHeight + (space - videoRealHeight) / 2;
267
//                        params.bottomMargin = DensityUtil.dip2px(getContext(), 152) + navHeight + (space - videoRealHeight) / 2;
268
//                    }
269
//                } else {
270
//                    int space = screenHeight - DensityUtil.dip2px(getContext(), 192) - statusBarHeight - navHeight;
271
//                    if (space > videoRealHeight) {
272
//                        params.topMargin = statusBarHeight + navHeight + navHeight + (space - videoRealHeight) / 2;
273
//                        params.bottomMargin = DensityUtil.dip2px(getContext(), 192) + navHeight + (space - videoRealHeight) / 2;
274
//                    }
275
//                }
276
            }
277
278
            videoPlayer.setVideoAllCallBack(new VideoAllCallBack() {
279
                @Override
280
                public void onAutoComplete(String s, Object... objects) {
281
                    if (MainApplication.autoPlayVideo) {
282
                        videoPlayer.startPlayLogic();
283
                    }
284
                }
285
286
                @Override
287
                public void onClickStartError(String s, Object... objects) {
288
                    playIcon.setVisibility(View.VISIBLE);
289
                    ToastUtil.showToast(getContext(), s, Toast.LENGTH_SHORT);
290
                }
291
292
                @Override
293
                public void onPlayError(String s, Object... objects) {
294
                    playIcon.setVisibility(View.VISIBLE);
295
                    ToastUtil.showToast(getContext(), s, Toast.LENGTH_SHORT);
296
                }
297
298
                @Override
299
                public void onStartPrepared(String s, Object... objects) {
300
                }
301
302
                @Override
303
                public void onPrepared(String s, Object... objects) {
304
                }
305
306
                @Override
307
                public void onClickResume(String s, Object... objects) {
308
                }
309
310
                @Override
311
                public void onClickBlank(String s, Object... objects) {
312
                }
313
314
                @Override
315
                public void onClickBlankFullscreen(String s, Object... objects) {
316
                }
317
318
                @Override
319
                public void onClickStartIcon(String s, Object... objects) {
320
                }
321
322
                @Override
323
                public void onClickStop(String s, Object... objects) {
324
325
                }
326
327
                @Override
328
                public void onClickStopFullscreen(String s, Object... objects) {
163 329
164
            videoPlayer.setBottomShowProgressBarDrawable(new ColorDrawable(getResources().getColor(android.R.color.holo_green_light)),new ColorDrawable(getResources().getColor(android.R.color.holo_blue_bright)));
330
                }
331
332
                @Override
333
                public void onClickResumeFullscreen(String s, Object... objects) {
334
335
                }
336
337
                @Override
338
                public void onClickSeekbar(String s, Object... objects) {
339
340
                }
341
342
                @Override
343
                public void onClickSeekbarFullscreen(String s, Object... objects) {
344
                }
345
346
                @Override
347
                public void onEnterFullscreen(String s, Object... objects) {
348
                }
349
350
                @Override
351
                public void onQuitFullscreen(String s, Object... objects) {
352
                }
353
354
                @Override
355
                public void onQuitSmallWidget(String s, Object... objects) {
356
                }
357
358
                @Override
359
                public void onEnterSmallWidget(String s, Object... objects) {
360
                }
361
362
                @Override
363
                public void onTouchScreenSeekVolume(String s, Object... objects) {
364
                }
365
366
                @Override
367
                public void onTouchScreenSeekPosition(String s, Object... objects) {
368
                }
165 369
370
                @Override
371
                public void onTouchScreenSeekLight(String s, Object... objects) {
372
                }
373
374
                @Override
375
                public void onClickStartThumb(String s, Object... objects) {
376
                }
377
            });
166 378
167 379
168 380
            /**
@ -173,45 +385,59 @@ public class ChatContentListActivity extends AppCompatActivity {
173 385
            videoPlayer.setGSYVideoProgressListener(new GSYVideoProgressListener() {
174 386
                @Override
175 387
                public void onProgress(int i, int i1, int i2, int i3) {
176
                    Log.d(TAG, "onProgress: " + i + ",i1:" + i1 + ",i2:" + i2 + ",i3:" + i3);
388
//                    if (i == 1) {
389
//                        videoPlayer.onVideoPause();
390
//                    }
391
//                    Log.d(TAG, "onProgress: " + i + ",i1:" + i1 + ",i2:" + i2 + ",i3:" + i3);
392
393
                    progressBar.setSecondaryProgress(i);
177 394
                }
178 395
            });
179 396
180
//            videoPlayer.startPlayLogic();
397
            ImageView thumbImageView = new ImageView(getContext());
398
            thumbImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
399
//            thumbImageView.setImageResource(R.drawable.app_publish_video_icon);
400
            ImageDisplayUtils.dispalyImg(getContext(), bean.coverImgUrl, thumbImageView);
401
            videoPlayer.setThumbImageView(thumbImageView);
181 402
182
            TextView positionTextView = rootView.findViewById(R.id.position);
183
            positionTextView.setText(bean.title);
184
        }
403
            rootView.findViewById(R.id.videoPlayerCover).setOnClickListener(new View.OnClickListener() {
404
                @Override
405
                public void onClick(View view) {
406
                    int currentStatue = videoPlayer.getCurrentState();
407
                    if (currentStatue == GSYVideoView.CURRENT_STATE_PLAYING) {
408
                        playIcon.setVisibility(View.VISIBLE);
409
                        videoPlayer.onVideoPause();
410
                    } else if (currentStatue == GSYVideoView.CURRENT_STATE_PAUSE) {
411
                        playIcon.setVisibility(View.GONE);
412
                        videoPlayer.onVideoResume(false);
413
                    } else {
414
                        playIcon.setVisibility(View.GONE);
415
                        videoPlayer.startPlayLogic();
416
                    }
417
                }
418
            });
185 419
186
        private void initPicturesView(View rootView, ChatRecommendBean bean) {
187
            TextView positionTextView = rootView.findViewById(R.id.position);
188
            positionTextView.setText(bean.title);
420
//            TextView positionTextView = rootView.findViewById(R.id.position);
421
//            positionTextView.setText(bean.title);
189 422
        }
190 423
191
        @Override
192
        public void onPause() {
193
            super.onPause();
194
            if (videoPlayer != null) {
195
                videoPlayer.onVideoPause();
424
        public void play() {
425
            if (videoPlayer == null) {
426
                return;
196 427
            }
197
198
        }
199
200
        @Override
201
        public void onResume() {
202
            super.onResume();
203
            if (videoPlayer != null) {
204
                videoPlayer.onVideoResume();
428
            playIcon.setVisibility(View.GONE);
429
            int currentStatue = videoPlayer.getCurrentState();
430
            if (currentStatue == GSYVideoView.CURRENT_STATE_PLAYING) {
431
            } else if (currentStatue == GSYVideoView.CURRENT_STATE_PAUSE) {
432
                videoPlayer.onVideoResume(true);
433
            } else {
434
                videoPlayer.startPlayLogic();
205 435
            }
206 436
        }
207 437
208
        @Override
209
        public void onDestroy() {
210
            super.onDestroy();
211
            GSYVideoADManager.releaseAllVideos();
212
            if (videoPlayer != null) {
213
                videoPlayer.setVideoAllCallBack(null);
214
            }
438
        private void initPicturesView(View rootView, ChatRecommendBean bean) {
439
            TextView positionTextView = rootView.findViewById(R.id.position);
440
            positionTextView.setText(bean.title);
215 441
        }
216 442
    }
217 443
}

+ 1 - 0
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

@ -127,6 +127,7 @@ public class MainApplication extends MultiDexApplication {
127 127
    public static boolean haveActivity = false;
128 128
    public static String ad_major = "";
129 129
    private String mCurrentCity = "";
130
    public static boolean autoPlayVideo = false;
130 131

131 132

132 133
    @SuppressLint("MissingPermission")

+ 146 - 0
app/src/main/java/com/electric/chargingpile/video/VideoPlayer.java

@ -0,0 +1,146 @@
1
package com.electric.chargingpile.video;
2
3
import android.content.Context;
4
import android.util.AttributeSet;
5
6
import com.electric.chargingpile.R;
7
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
8
9
public class VideoPlayer extends StandardGSYVideoPlayer {
10
    public VideoPlayer(Context context, Boolean fullFlag) {
11
        super(context, fullFlag);
12
    }
13
14
    public VideoPlayer(Context context) {
15
        super(context);
16
    }
17
18
    public VideoPlayer(Context context, AttributeSet attrs) {
19
        super(context, attrs);
20
    }
21
22
//    @Override
23
//    public int getLayoutId() {
24
//        return R.layout.video_player;
25
//    }
26
27
    @Override
28
    protected void touchSurfaceMoveFullLogic(float absDeltaX, float absDeltaY) {
29
        super.touchSurfaceMoveFullLogic(absDeltaX, absDeltaY);
30
        //不给触摸快进,如果需要,屏蔽下方代码即可
31
        mChangePosition = false;
32
33
        //不给触摸音量,如果需要,屏蔽下方代码即可
34
        mChangeVolume = false;
35
36
        //不给触摸亮度,如果需要,屏蔽下方代码即可
37
        mBrightness = false;
38
    }
39
40
    @Override
41
    protected void touchDoubleUp() {
42
        // super.touchDoubleUp();
43
        // 不需要双击暂停
44
    }
45
46
    @Override
47
    protected void changeUiToPreparingShow() {
48
        super.changeUiToPreparingShow();
49
        setViewShowState(mTopContainer, INVISIBLE);
50
        setViewShowState(mBottomContainer, INVISIBLE);
51
        setViewShowState(mLoadingProgressBar, INVISIBLE);
52
        setViewShowState(mStartButton, INVISIBLE);
53
        setViewShowState(mBottomProgressBar, INVISIBLE);
54
        setViewShowState(mProgressBar, INVISIBLE);
55
    }
56
57
    @Override
58
    protected void changeUiToPlayingBufferingShow() {
59
        super.changeUiToPlayingBufferingShow();
60
        setViewShowState(mTopContainer, INVISIBLE);
61
        setViewShowState(mBottomContainer, INVISIBLE);
62
        setViewShowState(mLoadingProgressBar, INVISIBLE);
63
        setViewShowState(mStartButton, INVISIBLE);
64
        setViewShowState(mBottomProgressBar, INVISIBLE);
65
        setViewShowState(mProgressBar, INVISIBLE);
66
    }
67
68
    @Override
69
    protected void changeUiToPlayingShow() {
70
        super.changeUiToPlayingShow();
71
        setViewShowState(mTopContainer, INVISIBLE);
72
        setViewShowState(mBottomContainer, INVISIBLE);
73
        setViewShowState(mLoadingProgressBar, INVISIBLE);
74
        setViewShowState(mStartButton, INVISIBLE);
75
        setViewShowState(mBottomProgressBar, INVISIBLE);
76
        setViewShowState(mProgressBar, INVISIBLE);
77
78
        mProgressBar.setProgressDrawable(getResources().getDrawable(R.drawable.video_player_progressbar));
79
    }
80
81
    @Override
82
    protected void changeUiToCompleteShow() {
83
        super.changeUiToCompleteShow();
84
        setViewShowState(mTopContainer, INVISIBLE);
85
        setViewShowState(mBottomContainer, INVISIBLE);
86
        setViewShowState(mLoadingProgressBar, INVISIBLE);
87
        setViewShowState(mStartButton, INVISIBLE);
88
        setViewShowState(mBottomProgressBar, INVISIBLE);
89
        setViewShowState(mProgressBar, INVISIBLE);
90
    }
91
92
    @Override
93
    protected void changeUiToPauseShow() {
94
        super.changeUiToPauseShow();
95
        setViewShowState(mTopContainer, INVISIBLE);
96
        setViewShowState(mBottomContainer, INVISIBLE);
97
        setViewShowState(mLoadingProgressBar, INVISIBLE);
98
        setViewShowState(mStartButton, INVISIBLE);
99
        setViewShowState(mBottomProgressBar, INVISIBLE);
100
        setViewShowState(mProgressBar, INVISIBLE);
101
    }
102
103
    @Override
104
    protected void changeUiToNormal() {
105
        super.changeUiToNormal();
106
        setViewShowState(mTopContainer, INVISIBLE);
107
        setViewShowState(mBottomContainer, INVISIBLE);
108
        setViewShowState(mLoadingProgressBar, INVISIBLE);
109
        setViewShowState(mStartButton, INVISIBLE);
110
        setViewShowState(mBottomProgressBar, INVISIBLE);
111
        setViewShowState(mProgressBar, INVISIBLE);
112
    }
113
114
    @Override
115
    public void startAfterPrepared() {
116
        super.startAfterPrepared();
117
        setViewShowState(mTopContainer, INVISIBLE);
118
        setViewShowState(mBottomContainer, INVISIBLE);
119
        setViewShowState(mLoadingProgressBar, INVISIBLE);
120
        setViewShowState(mStartButton, INVISIBLE);
121
        setViewShowState(mBottomProgressBar, INVISIBLE);
122
        setViewShowState(mProgressBar, INVISIBLE);
123
    }
124
125
    @Override
126
    protected void changeUiToPlayingBufferingClear() {
127
        super.changeUiToPlayingBufferingClear();
128
        setViewShowState(mTopContainer, INVISIBLE);
129
        setViewShowState(mBottomContainer, INVISIBLE);
130
        setViewShowState(mLoadingProgressBar, INVISIBLE);
131
        setViewShowState(mStartButton, INVISIBLE);
132
        setViewShowState(mBottomProgressBar, INVISIBLE);
133
        setViewShowState(mProgressBar, INVISIBLE);
134
    }
135
136
    @Override
137
    protected void changeTextureViewShowType() {
138
        super.changeTextureViewShowType();
139
        setViewShowState(mTopContainer, INVISIBLE);
140
        setViewShowState(mBottomContainer, INVISIBLE);
141
        setViewShowState(mLoadingProgressBar, INVISIBLE);
142
        setViewShowState(mStartButton, INVISIBLE);
143
        setViewShowState(mBottomProgressBar, INVISIBLE);
144
        setViewShowState(mProgressBar, INVISIBLE);
145
    }
146
}

+ 25 - 0
app/src/main/res/drawable/video_player_progressbar.xml

@ -0,0 +1,25 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3
    <!--默认颜色-->
4
    <item android:id="@android:id/background">
5
        <shape>
6
            <solid android:color="#424242" />
7
        </shape>
8
    </item>
9
    <!--进度颜色-->
10
    <item android:id="@android:id/progress">
11
        <clip>
12
            <shape>
13
                <solid android:color="@color/white" />
14
            </shape>
15
        </clip>
16
    </item>
17
    <!--第二进度颜色-->
18
    <item android:id="@android:id/secondaryProgress">
19
        <clip>
20
            <shape>
21
                <solid android:color="#00edb2" />
22
            </shape>
23
        </clip>
24
    </item>
25
</layer-list>

+ 46 - 11
app/src/main/res/layout/fragment_chat_content_video.xml

@ -4,24 +4,59 @@
4 4
    xmlns:tools="http://schemas.android.com/tools"
5 5
    android:layout_width="match_parent"
6 6
    android:layout_height="match_parent"
7
    android:background="#990545">
7
    android:background="#424242">
8 8
9
    <com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
9
    <com.electric.chargingpile.video.VideoPlayer
10 10
        android:id="@+id/videoPlayer"
11 11
        android:layout_width="match_parent"
12
        android:layout_height="wrap_content"
13
        app:layout_constraintBottom_toBottomOf="parent"
12
        android:layout_height="match_parent"
13
        app:layout_constraintTop_toTopOf="parent"
14 14
        app:layout_constraintEnd_toEndOf="parent"
15
        app:layout_constraintStart_toStartOf="parent"
16
        app:layout_constraintTop_toTopOf="parent" />
15
        app:layout_constraintBottom_toBottomOf="parent"
16
        app:layout_constraintStart_toStartOf="parent">
17
    </com.electric.chargingpile.video.VideoPlayer>
17 18
18
    <TextView
19
        android:id="@+id/position"
19
    <ImageView
20
        android:id="@+id/playIcon"
20 21
        android:layout_width="wrap_content"
21 22
        android:layout_height="wrap_content"
22
        android:layout_marginTop="20dp"
23
        android:text="TextView"
23
        android:clickable="false"
24
        android:src="@drawable/app_talk_video_icon"
25
        app:layout_constraintBottom_toBottomOf="@+id/videoPlayer"
26
        app:layout_constraintEnd_toEndOf="@+id/videoPlayer"
27
        app:layout_constraintStart_toStartOf="@+id/videoPlayer"
28
        app:layout_constraintTop_toTopOf="@+id/videoPlayer" />
29
30
    <android.support.constraint.ConstraintLayout
31
        android:id="@+id/videoPlayerCover"
32
        android:layout_width="match_parent"
33
        android:layout_height="match_parent"
34
        app:layout_constraintBottom_toBottomOf="parent"
35
        app:layout_constraintLeft_toLeftOf="parent"
36
        app:layout_constraintRight_toRightOf="parent"
37
        app:layout_constraintTop_toTopOf="parent">
38
    </android.support.constraint.ConstraintLayout>
39
40
    <ProgressBar
41
        android:id="@+id/progressBar"
42
        android:visibility="gone"
43
        style="@android:style/Widget.ProgressBar.Horizontal"
44
        android:layout_width="match_parent"
45
        android:layout_height="1dp"
46
        android:max="100"
47
        tools:progress="50"
48
        android:progressDrawable="@drawable/video_player_progressbar"
49
        app:layout_constraintBottom_toTopOf="parent"
24 50
        app:layout_constraintEnd_toEndOf="parent"
25 51
        app:layout_constraintStart_toStartOf="parent"
26
        app:layout_constraintTop_toTopOf="parent" />
52
        tools:layout_height="10dp"
53
        tools:secondaryProgress="10" />
54
55
    <ImageView
56
        android:id="@+id/testImg"
57
        android:background="#0000ee"
58
        android:layout_width="match_parent"
59
        app:layout_constraintLeft_toLeftOf="parent"
60
        app:layout_constraintTop_toTopOf="parent"
61
        android:layout_height="5dp" />
27 62
</android.support.constraint.ConstraintLayout>

+ 18 - 0
app/src/main/res/layout/video_player.xml

@ -0,0 +1,18 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    android:layout_width="match_parent"
5
    android:background="#424242"
6
    android:layout_height="match_parent">
7
8
    <FrameLayout
9
        android:id="@+id/surface_container"
10
        android:layout_width="match_parent"
11
        android:foregroundGravity="center"
12
        android:layout_height="match_parent"
13
        app:layout_constraintBottom_toBottomOf="parent"
14
        app:layout_constraintEnd_toEndOf="parent"
15
        app:layout_constraintStart_toStartOf="parent"
16
        app:layout_constraintTop_toTopOf="parent"></FrameLayout>
17
18
</android.support.constraint.ConstraintLayout>

dudu/cdzApp - Gogs: Go Git Service

6 Commits (35c232cb5c39cc084e82ce044f731678cc2daeb9)

Autore SHA1 Messaggio Data
  huyuguo 769b760623 信息流列表开发 6 anni fa
  huyuguo 6bda32c0a1 版本号修改 6 anni fa
  huyuguo a09e4b2d81 忽略文件更新 6 anni fa
  1145873331@qq.com 2fa5ae59bf remove 7 anni fa
  dxh 10ce0c6dcc Merge branch 'master' of /Users/dxh/android_chargingpile with conflicts. 7 anni fa
  dxh 06bd894653 init 7 anni fa