add videoplay
This commit is contained in:
@@ -1,2 +1,12 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.tanlu" />
|
||||
package="com.mogo.tanlu">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".video.FullMediaActivity"
|
||||
android:hardwareAccelerated="true">
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mogo.tanlu.constant
|
||||
|
||||
const val REQUESTCODE_MAINACTIVITY = 0
|
||||
const val REQUESTCODE_MEDIAACTIVITY = 1
|
||||
|
||||
//EXTRA_STATE
|
||||
const val AUTO_NAVI_START = 8 //开始导航
|
||||
const val AUTO_NAVI_END = 9 //结束导航
|
||||
@@ -9,4 +9,5 @@ package com.mogo.tanlu.constant;
|
||||
public class TanluConstants {
|
||||
|
||||
public static final String TAG = "/tanlu/ui";
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
@@ -24,9 +25,15 @@ import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
||||
import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.service.imageloader.MogoImageView;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.tanlu.R;
|
||||
import com.mogo.tanlu.video.FullMediaActivity;
|
||||
import com.mogo.tanlu.video.SimpleCoverVideoPlayer;
|
||||
import com.mogo.tanlu.view.AutoZoomInImageView;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
|
||||
@@ -52,10 +59,11 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
private TanluInfoWindowAdapter mDemoInfoWindowAdapter;
|
||||
private int position = -1;
|
||||
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
||||
private String videoUrl = "http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/CarPad/com.zhidao.roadcondition/ZD801B1942L02537/ZD801B1942L02537_20200103161355/PhotoFront_20200103_161351.JPG?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDCWfcNwD5PXVWLxwejccR3Tiz5zhIkx0T%26q-sign-time%3D1578042652%3B1578049852%26q-key-time%3D1578042652%3B1578049852%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3Db9530357bc3d80fb13ec54dfaa9a7a1ee86180e2";
|
||||
// private String videoUrl = "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8";
|
||||
// private String videoUrl = "http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/CarPad/com.zhidao.roadcondition/ZD801B1942L02537/ZD801B1942L02537_20200103161355/PhotoFront_20200103_161351.JPG?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDCWfcNwD5PXVWLxwejccR3Tiz5zhIkx0T%26q-sign-time%3D1578042652%3B1578049852%26q-key-time%3D1578042652%3B1578049852%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3Db9530357bc3d80fb13ec54dfaa9a7a1ee86180e2";
|
||||
private String videoUrl = "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8";
|
||||
SimpleCoverVideoPlayer simpleCoverVideoPlayer;
|
||||
|
||||
AutoZoomInImageView autoZoomInImageView;
|
||||
private IMogoImageloader mogoImageloader;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -67,6 +75,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
initVideo();
|
||||
position = getArguments().getInt("position");
|
||||
simpleCoverVideoPlayer = findViewById(R.id.video_player_main);
|
||||
autoZoomInImageView = findViewById(R.id.tanlu_photo_imageView);
|
||||
|
||||
//视频配置
|
||||
gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
@@ -76,15 +85,19 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.d("liyz", "onClick ---------> ");
|
||||
Intent intent = new Intent("fullscreen.video.play", Uri.parse("video://666"));
|
||||
getActivity().startActivity(intent);
|
||||
// Intent intent = new Intent("fullscreen.video.play", Uri.parse("video://666"));
|
||||
// getActivity().startActivity(intent);
|
||||
|
||||
FullMediaActivity.Companion.launch(getActivity(), videoUrl, "image");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//图片显示
|
||||
mogoImageloader = (IMogoImageloader) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_IMAGE_LOADER ).navigation();
|
||||
mogoImageloader.displayImage("https://oimagec4.ydstatic.com/image?id=-5397300958976572132&product=adpublish&w=520&h=347", autoZoomInImageView);
|
||||
|
||||
|
||||
|
||||
//当前定位信息
|
||||
TanluServiceHandler.getPoiSearch().setPoiSearchListener(this);
|
||||
// mLocation = TanluServiceHandler.getLocationClient().getLastKnowLocation();
|
||||
mDemoInfoWindowAdapter = new TanluInfoWindowAdapter(getContext(), TanluServiceHandler.getNavi(), TanluServiceHandler.getImageloader());
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.mogo.tanlu.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 列表数据
|
||||
* @since 2020-01-05
|
||||
*/
|
||||
public class Information implements Parcelable {
|
||||
private int type;
|
||||
private Double lon;
|
||||
private Double lat;
|
||||
private String addr;
|
||||
private Long generateTime;
|
||||
private String cityName;
|
||||
private ArrayList<Items> items;
|
||||
private int distance;
|
||||
private String nickName;
|
||||
private String headImgUrl;
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.type);
|
||||
dest.writeValue(this.lon);
|
||||
dest.writeValue(this.lat);
|
||||
dest.writeString(this.addr);
|
||||
dest.writeValue(this.generateTime);
|
||||
dest.writeString(this.cityName);
|
||||
dest.writeTypedList(this.items);
|
||||
dest.writeInt(this.distance);
|
||||
dest.writeString(this.nickName);
|
||||
dest.writeString(this.headImgUrl);
|
||||
}
|
||||
|
||||
public Information() {
|
||||
}
|
||||
|
||||
protected Information(Parcel in) {
|
||||
this.type = in.readInt();
|
||||
this.lon = (Double) in.readValue(Double.class.getClassLoader());
|
||||
this.lat = (Double) in.readValue(Double.class.getClassLoader());
|
||||
this.addr = in.readString();
|
||||
this.generateTime = (Long) in.readValue(Long.class.getClassLoader());
|
||||
this.cityName = in.readString();
|
||||
this.items = in.createTypedArrayList(Items.CREATOR);
|
||||
this.distance = in.readInt();
|
||||
this.nickName = in.readString();
|
||||
this.headImgUrl = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<Information> CREATOR = new Creator<Information>() {
|
||||
@Override
|
||||
public Information createFromParcel(Parcel source) {
|
||||
return new Information(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Information[] newArray(int size) {
|
||||
return new Information[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mogo.tanlu.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.amap.api.maps.model.LatLng
|
||||
|
||||
fun Informations.toLatLng(): LatLng {
|
||||
return LatLng(lat, lon)
|
||||
}
|
||||
|
||||
class Informations(
|
||||
var type: Int,
|
||||
var lon: Double,
|
||||
var lat: Double,
|
||||
var addr: String?,
|
||||
var generateTime: Long,
|
||||
var cityName: String?,
|
||||
// var items: ArrayList<Items>,
|
||||
var distance: Int,
|
||||
var nickName: String?,
|
||||
var headImgUrl: String?
|
||||
) :
|
||||
Parcelable {
|
||||
|
||||
var position = 0
|
||||
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readInt(),
|
||||
parcel.readDouble(),
|
||||
parcel.readDouble(),
|
||||
parcel.readString(),
|
||||
parcel.readLong(),
|
||||
parcel.readString(),
|
||||
// parcel.readArrayList(Items::class.java.classLoader) as ArrayList<Items>,
|
||||
parcel.readInt(),
|
||||
parcel.readString(),
|
||||
parcel.readString()
|
||||
)
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeInt(type)
|
||||
parcel.writeDouble(lon)
|
||||
parcel.writeDouble(lat)
|
||||
parcel.writeString(addr)
|
||||
parcel.writeLong(generateTime)
|
||||
parcel.writeString(cityName)
|
||||
// parcel.writeList(items)
|
||||
parcel.writeInt(distance)
|
||||
parcel.writeString(nickName)
|
||||
parcel.writeString(headImgUrl)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Informations> {
|
||||
override fun createFromParcel(parcel: Parcel): Informations {
|
||||
return Informations(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Informations?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.mogo.tanlu.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
class Items(var url: String? = null, var thumbnail: String? = null) : Parcelable {
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readString(),
|
||||
parcel.readString()
|
||||
) {
|
||||
}
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeString(url)
|
||||
parcel.writeString(thumbnail)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Items> {
|
||||
override fun createFromParcel(parcel: Parcel): Items {
|
||||
return Items(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Items?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.tanlu.model.global
|
||||
|
||||
import com.mogo.tanlu.model.Information
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-02
|
||||
*
|
||||
* 共享的情报列表,避免在点击大屏查看视频时intent序列化造成的开销
|
||||
*/
|
||||
object GlobalSharedInformation {
|
||||
|
||||
var informationList: ArrayList<Information>? = null
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.tanlu.util
|
||||
|
||||
|
||||
|
||||
const val SPACE_TIME = 1000
|
||||
var lastClickTime = 0L
|
||||
var viewId: Int = 0
|
||||
|
||||
fun isDoubleClick(view: Int): Boolean {
|
||||
val time = System.currentTimeMillis()
|
||||
val timeD = time - lastClickTime
|
||||
if (timeD < SPACE_TIME && viewId == view) {
|
||||
return true
|
||||
}
|
||||
lastClickTime = time
|
||||
viewId = view
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
fun isDoubleClickTime(view: Int,spaceTime:Int): Boolean {
|
||||
val time = System.currentTimeMillis()
|
||||
val timeD = time - lastClickTime
|
||||
if (timeD < spaceTime && viewId == view) {
|
||||
return true
|
||||
}
|
||||
lastClickTime = time
|
||||
viewId = view
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mogo.tanlu.util
|
||||
|
||||
import android.os.Message
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.Group
|
||||
|
||||
class HideControl {
|
||||
|
||||
companion object {
|
||||
const val MSG_HIDE = 0x01
|
||||
}
|
||||
|
||||
private var mHideHandler: HideHandler = HideHandler()
|
||||
var view1: Group? = null
|
||||
var view2: Group? = null
|
||||
|
||||
val hideRunable = Runnable {
|
||||
mHideHandler.obtainMessage(MSG_HIDE).sendToTarget()
|
||||
}
|
||||
|
||||
private inner class HideHandler : android.os.Handler() {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
when (msg.what) {
|
||||
MSG_HIDE -> {
|
||||
view1?.let {
|
||||
it.visibility = View.GONE
|
||||
}
|
||||
view2?.let {
|
||||
it.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun startHideTimer(view1: Group,view2: Group? = null) {
|
||||
this.view1 = view1
|
||||
this.view2 = view2
|
||||
mHideHandler.removeCallbacks(hideRunable)
|
||||
if (view1.visibility == View.GONE) {
|
||||
view1.visibility = View.VISIBLE
|
||||
}
|
||||
if (view2?.visibility == View.GONE) {
|
||||
view2.visibility = View.VISIBLE
|
||||
}
|
||||
mHideHandler.postDelayed(hideRunable, 3000)
|
||||
}
|
||||
|
||||
fun resetHideTimer() {
|
||||
if(view1 != null){
|
||||
view1!!.visibility = View.VISIBLE
|
||||
}
|
||||
if(view2 != null){
|
||||
view2!!.visibility = View.VISIBLE
|
||||
}
|
||||
mHideHandler.removeCallbacks(hideRunable)
|
||||
mHideHandler.postDelayed(hideRunable, 3000)
|
||||
}
|
||||
|
||||
fun endHideTime() {
|
||||
mHideHandler.removeCallbacks(hideRunable)
|
||||
if (view1 != null) {
|
||||
view1 = null
|
||||
}
|
||||
if (view2 != null) {
|
||||
view2 = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.mogo.tanlu.video
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.mogo.tanlu.R
|
||||
import com.mogo.tanlu.constant.REQUESTCODE_MAINACTIVITY
|
||||
import com.mogo.tanlu.model.Informations
|
||||
import com.mogo.tanlu.model.global.GlobalSharedInformation
|
||||
import com.mogo.tanlu.util.HideControl
|
||||
import com.mogo.tanlu.util.isDoubleClickTime
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
|
||||
import kotlinx.android.synthetic.main.tanlu_activity_media_full.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 全屏显示适配
|
||||
*/
|
||||
|
||||
class FullMediaActivity : AppCompatActivity(), View.OnClickListener {
|
||||
companion object {
|
||||
const val PARAM_MEDIA_DATA = "PARAM_MEDIA_DATA"
|
||||
const val PARAM_MEDIA_POSITION_CALLBACK = "PARAM_MEDIA_POSITION_CALLBACK"
|
||||
const val TAG = "FullMediaActivity"
|
||||
|
||||
const val PARAM_VIDEO_URL = "param_video_url"
|
||||
const val PARAM_THUMB_URL = "param_thumb_url"
|
||||
|
||||
|
||||
// fun launch(context: Activity, strategyInfo: List<Informations>, position: Int) {
|
||||
// val intent = Intent(context, FullMediaActivity::class.java)
|
||||
// intent.putExtra(PARAM_MEDIA_POSITION, position)
|
||||
// // 使用全局静态对象代替,避免序列化开销
|
||||
// GlobalSharedInformation.informationList = strategyInfo as ArrayList<Informations>
|
||||
// context.startActivityForResult(intent, REQUESTCODE_MAINACTIVITY)
|
||||
// context.overridePendingTransition(0, 0)
|
||||
// }
|
||||
|
||||
fun launch(context: Activity, videoUrl: String, thumbnail: String) {
|
||||
val intent = Intent(context, FullMediaActivity::class.java)
|
||||
intent.putExtra(PARAM_VIDEO_URL, videoUrl)
|
||||
intent.putExtra(PARAM_THUMB_URL, thumbnail)
|
||||
context.startActivity(intent)
|
||||
context.overridePendingTransition(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
private var strategyInfo: ArrayList<Informations> = arrayListOf()
|
||||
private var currentImgPosition: Int = 0
|
||||
private var currentPosition: Int = 50
|
||||
private var control = HideControl()
|
||||
|
||||
private var gsyVideoOptionBuilder = GSYVideoOptionBuilder()
|
||||
private var videoUrl: String? = null
|
||||
private var thumbUrl: String? = null
|
||||
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.tanlu_activity_media_full)
|
||||
handleIntent()
|
||||
setListener()
|
||||
}
|
||||
|
||||
private fun handleIntent() {
|
||||
var intent = intent
|
||||
|
||||
videoUrl = intent.getStringExtra(PARAM_VIDEO_URL)
|
||||
thumbUrl = intent.getStringExtra(PARAM_THUMB_URL)
|
||||
|
||||
Log.e("liyz", "videoUrl = $videoUrl --->thumbUrl = $thumbUrl")
|
||||
// currentPosition += strategyInfo.size * 10000
|
||||
// if (strategyInfo.size == 1) {
|
||||
// group_media_page_up.visibility = View.GONE
|
||||
// group_media_page_up.updatePreLayout(cl_media)
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateInformation()
|
||||
GSYVideoManager.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
GSYVideoManager.onPause()
|
||||
}
|
||||
|
||||
//需要监听完成事件
|
||||
private fun setListener() {
|
||||
iv_media_back.setOnClickListener(this)
|
||||
|
||||
//重置timer
|
||||
video_view.addSingleClickListener(object :
|
||||
MediaCoverVideoPlayer.SingleClickListener {
|
||||
override fun onClick() {
|
||||
control.resetHideTimer()
|
||||
}
|
||||
})
|
||||
|
||||
//视频播放完成
|
||||
video_view.onCompletionListener(object :
|
||||
MediaCoverVideoPlayer.CompletionListener {
|
||||
override fun onCompletion() {
|
||||
GSYVideoManager.releaseAllVideos()
|
||||
finish()
|
||||
}
|
||||
})
|
||||
|
||||
video_view.loadCoverImage(thumbUrl!!)
|
||||
//设置url,点击播放
|
||||
gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(true)
|
||||
.setPlayTag(TAG).build(video_view)
|
||||
video_view.startButton.performClick()
|
||||
}
|
||||
|
||||
private fun updateInformation() {
|
||||
// tv_media_title_content.text = strategyInfo!![currentImgPosition].addr
|
||||
// tv_media_title_time.text = formatDate(strategyInfo!![currentImgPosition].generateTime)
|
||||
}
|
||||
|
||||
|
||||
override fun onClick(view: View) {
|
||||
view?.let {
|
||||
when (view) {
|
||||
iv_media_back -> {
|
||||
handleBack()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
GSYVideoManager.releaseAllVideos()
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
|
||||
private fun handleBack() {
|
||||
Log.d("liyz", "handleBack ------> finish ")
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
handleBack()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.mogo.tanlu.video
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.mogo.tanlu.R
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
|
||||
|
||||
|
||||
/**
|
||||
* 全屏播放
|
||||
*/
|
||||
class MediaCoverVideoPlayer : StandardGSYVideoPlayer {
|
||||
|
||||
private lateinit var coverImage: ImageView
|
||||
private lateinit var start: ImageView
|
||||
private lateinit var fullscreen: ImageView
|
||||
private lateinit var singleClickListener: SingleClickListener
|
||||
private lateinit var completionListener: CompletionListener
|
||||
|
||||
constructor(context: Context?) : super(context)
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context?, fullFlag: Boolean?) : super(context, fullFlag)
|
||||
|
||||
interface SingleClickListener {
|
||||
fun onClick()
|
||||
}
|
||||
|
||||
interface CompletionListener {
|
||||
fun onCompletion()
|
||||
}
|
||||
|
||||
override fun init(context: Context) {
|
||||
super.init(context)
|
||||
coverImage = findViewById(R.id.thumbImage)
|
||||
start = findViewById(R.id.start)
|
||||
fullscreen = findViewById(R.id.fullscreen)
|
||||
if (mThumbImageViewLayout != null
|
||||
&& (mCurrentState == -1 || mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL || mCurrentState == GSYVideoView.CURRENT_STATE_ERROR)
|
||||
) {
|
||||
mThumbImageViewLayout.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
fun addSingleClickListener(singleClickListener: SingleClickListener) {
|
||||
this.singleClickListener = singleClickListener
|
||||
}
|
||||
|
||||
fun onCompletionListener(completionListener: CompletionListener) {
|
||||
this.completionListener = completionListener
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.tanlu_item_video_cover_media
|
||||
}
|
||||
|
||||
override fun getGSYVideoManager(): GSYVideoViewBridge {
|
||||
GSYVideoManager.instance().initContext(context.applicationContext)
|
||||
return GSYVideoManager.instance()
|
||||
}
|
||||
|
||||
override fun setProgressAndTime(
|
||||
progress: Int,
|
||||
secProgress: Int,
|
||||
currentTime: Int,
|
||||
totalTime: Int
|
||||
) {
|
||||
super.setProgressAndTime(progress, secProgress, currentTime, totalTime)
|
||||
if (progress != 0) {
|
||||
mProgressBar.progress = progress
|
||||
}
|
||||
}
|
||||
|
||||
fun loadCoverImage(url: String) {
|
||||
Glide.with(context)
|
||||
.load(url)
|
||||
.into(coverImage)
|
||||
}
|
||||
|
||||
override fun updateStartImage() {
|
||||
when (mCurrentState) {
|
||||
GSYVideoView.CURRENT_STATE_PLAYING -> start.setImageResource(R.drawable.selector_bg_btn_pause)
|
||||
GSYVideoView.CURRENT_STATE_ERROR -> start.setImageResource(R.mipmap.main_video_refresh_btn)
|
||||
else -> start.setImageResource(R.drawable.selector_bg_btn_play)
|
||||
}
|
||||
}
|
||||
|
||||
fun setFullClickListener(listener: OnClickListener) {
|
||||
fullscreen.setOnClickListener(listener)
|
||||
}
|
||||
|
||||
override fun onClickUiToggle() {
|
||||
super.onClickUiToggle()
|
||||
singleClickListener.let {
|
||||
it.onClick()
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeUiToCompleteShow() {
|
||||
super.changeUiToCompleteShow()
|
||||
setViewShowState(mBottomContainer, View.INVISIBLE)
|
||||
}
|
||||
|
||||
override fun onAutoCompletion() {
|
||||
super.onAutoCompletion()
|
||||
mProgressBar.progress = 0
|
||||
}
|
||||
|
||||
override fun showWifiDialog() {
|
||||
//直接播放,不显示WIFI对话框
|
||||
startPlayLogic()
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
super.onClick(v)
|
||||
v?.let {
|
||||
when (v) {
|
||||
start -> {
|
||||
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPrepared() {
|
||||
super.onPrepared()
|
||||
}
|
||||
|
||||
/**
|
||||
* 多次回调? TODO
|
||||
*/
|
||||
override fun onCompletion() {
|
||||
Log.d("liyz", "onCompletion --------->")
|
||||
// completionListener.let {
|
||||
// it.onCompletion()
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
mFullPauseBitmap?.let {
|
||||
if (!it.isRecycled) {
|
||||
it.recycle()
|
||||
}
|
||||
}
|
||||
mFullPauseBitmap = null
|
||||
Log.d("MediaCoverVideoPlayer", "recycle.")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,8 +9,9 @@ import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.mogo.service.imageloader.MogoImageView
|
||||
|
||||
class AutoZoomInImageView : ImageView {
|
||||
class AutoZoomInImageView : MogoImageView {
|
||||
|
||||
companion object {
|
||||
const val TAG = "AutoZoomInImageView"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/main_solid_left_page_up_press" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/main_solid_left_page_up_normal" android:state_pressed="false"/>
|
||||
<item android:drawable="@drawable/main_solid_left_page_up_normal"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/main_solid_right_page_up_press" android:state_pressed="true"/>
|
||||
<item android:drawable="@drawable/main_solid_right_page_up_normal" android:state_pressed="false"/>
|
||||
<item android:drawable="@drawable/main_solid_right_page_up_normal"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/cl_media"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".video.FullMediaActivity">
|
||||
|
||||
<!--全屏播放器-->
|
||||
<com.mogo.tanlu.video.MediaCoverVideoPlayer
|
||||
android:id="@+id/video_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:longClickable="true" />
|
||||
|
||||
<!--顶部区域-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout_media"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="84dp"
|
||||
android:background="@color/color_323131"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_media_back"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/public_arrow_back_iv"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_media_title_content"
|
||||
android:layout_width="560dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxWidth="560dp"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_media_title_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_marginTop="58dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="17dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/group_media"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="constraintLayout_media" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -36,19 +36,32 @@
|
||||
android:textSize="20dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<!--播放器-->
|
||||
<com.mogo.tanlu.video.SimpleCoverVideoPlayer
|
||||
android:id="@+id/video_player_main"
|
||||
<!--视频播放器和图片播放器-->
|
||||
<RelativeLayout
|
||||
android:id="@+id/media_layout"
|
||||
android:layout_below="@+id/layout_top_view"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="225dp"
|
||||
android:layout_below="@+id/layout_top_view" />
|
||||
android:layout_height="225dp">
|
||||
|
||||
<com.mogo.tanlu.video.SimpleCoverVideoPlayer
|
||||
android:id="@+id/video_player_main"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<com.mogo.tanlu.view.AutoZoomInImageView
|
||||
android:id="@+id/tanlu_photo_imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!--底部view-->
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:background="@drawable/shape_bg_222533_6px_bottom"
|
||||
android:layout_below="@+id/video_player_main">
|
||||
android:layout_below="@+id/media_layout">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/username_image_video"
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/item_video_cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/surface_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/thumb"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thumbImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="72dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:background="@color/color_99191C25"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:max="100"
|
||||
android:maxHeight="4dp"
|
||||
android:minHeight="4dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:progressDrawable="@drawable/video_seek_progress"
|
||||
android:thumb="@drawable/video_seek_thumb" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/fullscreen"
|
||||
android:visibility="gone"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:scaleType="centerInside" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/start"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:indeterminateDrawable="@drawable/loading_bg"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user