Kotlin高仿微信-第28篇-朋友圈-预览图片、预览小视频
创始人
2024-03-06 14:01:29
0

 Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。

Kotlin高仿微信-项目实践58篇,点击查看详情

效果图:

实现代码:

/*** Author : wangning* Email : maoning20080809@163.com* Date : 2022/5/24 16:11* Description : 朋友圈小视频播放*/
class SVideoPlayFragment : BaseDataBindingFragment(){override fun getLayoutRes() = R.layout.wc_svideo_playprivate var navController: NavController? = nullprivate var enterType: Int = 0private var isHideConfirm : Boolean = falseprivate var svideoView: SVideoView? = nulloverride fun onViewCreated(view: View, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState)navController = findNavController()svideoView = svideo_play_view//2图片、3、小视频var type = arguments?.get(CommonUtils.Moments.TYPE_NAME) as Intvar filePath = arguments?.get(CommonUtils.Moments.TYPE_IMAGE_PATH).toString()//小视频路径var videoFilePath = arguments?.get(CommonUtils.Moments.TYPE_VIDEO_PATH).toString()//enterType = arguments?.get(CameraFragment.TYPE_ENTER)arguments?.let {it.get(CameraFragment.TYPE_ENTER)?.let {enterType = it as Int}it.get(CommonUtils.Chat.IS_HIDE_CONFIRM)?.let {isHideConfirm = it as Boolean}}if(type.equals(CommonUtils.Moments.TYPE_PICTURE)){super.builder().setTitleContent(R.string.me_moments_picture_preview)svideo_play_view.visibility = View.GONEphoto_preview_icon.visibility = View.VISIBLEvar degree = ImageUtils.getExifOrientation(filePath)TagUtils.d("图片角度:${degree} , 图片路径:${filePath}")if(degree == 0){GlideUtils.load(photo_preview_icon, filePath)} else {GlideUtils.loadRounded(photo_preview_icon, filePath, degree)}} else if(type.equals(CommonUtils.Moments.TYPE_VIDEO)){super.builder().setTitleContent(R.string.me_moments_video_preview)svideo_play_view.visibility = View.VISIBLEphoto_preview_icon.visibility = View.GONETagUtils.d("播放小视频文件:${videoFilePath}")svideo_play_view.initData(videoFilePath, true)}if(isHideConfirm){photo_preview_confirm.visibility = View.GONE}photo_preview_confirm.setOnClickListener {TagUtils.d("点击返回按钮:${enterType}")if(enterType == CameraFragment.TYPE_CHAT){var sVideoBean : SVideoBean? = nullif(type.equals(CommonUtils.Moments.TYPE_PICTURE)){//图片sVideoBean = SVideoBean(type, filePath)} else if(type.equals(CommonUtils.Moments.TYPE_VIDEO)){//小视频sVideoBean = SVideoBean(type, videoFilePath)}EventBus.getDefault().post(sVideoBean)navController?.popBackStack(R.id.nav_chat, false)} else if(enterType == CameraFragment.TYPE_MOMENT){TagUtils.d("跳转到发布:${type}, ${videoFilePath} , ${filePath}")navController?.popBackStack()var bundle = bundleOf(CommonUtils.Moments.TYPE_NAME to type,CommonUtils.Moments.TYPE_IMAGE_PATH to filePath,CommonUtils.Moments.TYPE_VIDEO_PATH to videoFilePath)navController?.navigate(R.id.action_moments_publish, bundle)} else {TagUtils.d("点击返回按钮:else  ")}}svideo_play_root.setOnClickListener {//svideo_play_view.onDestroy()svideoView?.onDestroy()Navigation.findNavController(it).popBackStack()}}override fun onResume() {super.onResume()}var isOnPause = falseoverride fun onStart() {super.onStart()if(isOnPause){svideoView?.onStart()isOnPause = false}}override fun onPause() {super.onPause()isOnPause = truesvideoView?.onStop()}override fun onStop() {super.onStop()}override fun onDestroy() {super.onDestroy()svideoView?.onDestroy()}}

相关内容

热门资讯

暴涨500%!19岁巴尔泰萨吉... 在意甲的舞台上,年轻球员的崛起往往令人瞩目,而19岁的巴尔泰萨吉正是近期最耀眼的新星之一。随着德转最...
完善幼儿园收费政策!三部门发文 来源 | 国家发展改革委微信,转自中国政府网微信 近日,国家发展改革委、教育部、财政部联合印发《关于...
老人“睡梦中”离世,警方靠共享... 孙大妈躺在床上 被子整整齐齐地盖在身上 就像睡着了一样 人却已经没有了呼吸 根据取款人的车辆骑行轨迹...
原创 中... 时值岁末,中航工业微信公众号中的说法,再一次引起了大家的注意。 近日,中航工业在“年末盘点”时,提...
“粤车南下”政策升级 今天起获... (央视财经《经济信息联播》)今天(23日)零时起,“粤车南下”驶入香港市区政策正式实施,广州、珠海、...
原创 李... 2025年12月23日零点,李艺彤在30岁生日当天,发文告别丝芭,强调"人生有梦,各自精彩"。丝芭1...
法律是否必然需要解释?新书《法... 本书聚焦法律解释的确定性或客观性问题——这是法治的一个重要预设,也是法哲学的一个核心难题。 为了回答...
山西调整烟花爆竹燃放政策 卫生... 中新网太原12月23日电 (记者 范丽芳)23日,记者从山西省卫生健康委员会获悉,针对山西调整烟花爆...
ST金鸿(000669)披露重... 截至2025年12月23日收盘,ST金鸿(000669)报收于3.02元,较前一交易日下跌1.31%...
三部门印发《关于完善幼儿园收费... 国家发展改革委、教育部、财政部联合印发的《关于完善幼儿园收费政策的通知》23日对外公布,旨在更好促进...