Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
xugenyuan
2024-07-09 18:16:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1ec4e6e5b75e61ea4d877b207c52e995c367e0d5
1ec4e6e5
1 parent
5e9c52b6
ref |> 直播IM消息显示,处理竖屏直播
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
35 deletions
sight_harmony/features/wdBean/src/main/ets/bean/live/LiveRoomBean.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/im/LiveRoom.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayLivePage.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayVLivePage.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/viewModel/LiveViewModel.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/TabChatComponent.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/ChartItemComponent.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerCommentComponent.ets
sight_harmony/features/wdBean/src/main/ets/bean/live/LiveRoomBean.ets
View file @
1ec4e6e
...
...
@@ -38,8 +38,14 @@ export interface LiveRoomItemBean {
fullColumnImgUrlDto: FullColumnImgUrlDTO
//观看人次
pv: string
// 自义定表情 - from im
///------- from IM
// 自义定表情
customizeExpression: number
// 已登录的用户id
senderUserId?: string
// 未登录的设备id
deviceId?: string
// 自定义字段
customFormIM?: boolean // 默认来自网络接口
...
...
@@ -72,3 +78,25 @@ export enum LiveMessageRoomType {
living = "ZH_VIDEO", // 直播间
chat = "ZH_CHAT", // 大家聊
}
export enum LiveMessageRole {
host = "host",
guest = "guest",
tourist = "tourist",
}
export function LiveMessageIsHistoryMessage(optionType: LiveMessageOptType): boolean {
let isHistoryMessage = false
switch (optionType) {
case LiveMessageOptType.ZH_TEXT_MSG:
case LiveMessageOptType.ZH_IMAGE_MSG:
case LiveMessageOptType.ZH_TEXT_AND_IMAGE_MSG:
case LiveMessageOptType.ZH_AUDIO_MSG:
case LiveMessageOptType.ZH_VIDEO_MSG: {
isHistoryMessage = true
} break;
default:
break;
}
return isHistoryMessage
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/im/LiveRoom.ets
View file @
1ec4e6e
...
...
@@ -10,7 +10,7 @@ import { LiveRoomItemBean } from 'wdBean/Index';
import { LiveRoomBaseInfo } from './LiveRoomBaseInfo'
import { JSON } from '@kit.ArkTS';
import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean';
import { LiveMessage
IsHistoryMessage, LiveMessage
OptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean';
const TAG = "LiveRoomManager"
...
...
@@ -109,7 +109,7 @@ export class LiveRoom extends ChatroomStatusListener {
let optionType = liveRoomItemBean.optionType != undefined ? liveRoomItemBean.optionType : liveRoomItemBean.dataType
if (
this.i
sHistoryMessage(optionType)) {
if (
LiveMessageI
sHistoryMessage(optionType)) {
liveRoomItemBean.customFormIM = true
if (this.onHistoryMessage) {
this.onHistoryMessage(liveRoomItemBean)
...
...
@@ -123,20 +123,4 @@ export class LiveRoom extends ChatroomStatusListener {
}
isHistoryMessage(optionType: string): boolean {
let isHistoryMessage = false
switch (optionType) {
case LiveMessageOptType.ZH_TEXT_MSG:
case LiveMessageOptType.ZH_IMAGE_MSG:
case LiveMessageOptType.ZH_TEXT_AND_IMAGE_MSG:
case LiveMessageOptType.ZH_AUDIO_MSG:
case LiveMessageOptType.ZH_VIDEO_MSG: {
isHistoryMessage = true
} break;
default:
break;
}
return isHistoryMessage
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayLivePage.ets
View file @
1ec4e6e
...
...
@@ -95,6 +95,10 @@ export struct DetailPlayLivePage {
configChatRoom() {
this.chatRoomController.onHistoryMessage = (liveRoomItemBean: LiveRoomItemBean) => {
const preDisplay = this.contentDetailData.liveInfo.preCommentFlag == 1
if (this.liveViewModel.filterMySelfCommentNoPreDisplay(liveRoomItemBean, preDisplay)) {
return
}
if (liveRoomItemBean.messageRoom == LiveMessageRoomType.living) {
this.lastInputedLiveComment = liveRoomItemBean
} else if (liveRoomItemBean.messageRoom == LiveMessageRoomType.chat) {
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayVLivePage.ets
View file @
1ec4e6e
import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index';
import { ContentDetailDTO, LiveRoomDataBean
, LiveRoomItemBean
} from 'wdBean/Index';
import { LiveViewModel } from '../viewModel/LiveViewModel';
import { CustomToast, WindowModel } from 'wdKit/Index';
import { PlayerComponent } from '../widgets/vertical/PlayerComponent';
...
...
@@ -12,6 +12,7 @@ import { LiveDetailPageLogic } from '../viewModel/LiveDetailPageLogic';
import { onlyWifiLoadVideo } from 'wdComponent/src/main/ets/utils/lazyloadImg';
import { StringUtils } from 'wdKit';
import { LiveDetailChatRoomController } from '../im/LiveDetailChatRoomController';
import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean';
const storage = LocalStorage.getShared();
const TAG = 'DetailPlayVLivePage'
...
...
@@ -40,6 +41,7 @@ export struct DetailPlayVLivePage {
@Consume contentId: string
@State swiperIndex: number = 1
@Consume liveDetailPageLogic: LiveDetailPageLogic
@Provide lastInputedComment: LiveRoomItemBean = {} as LiveRoomItemBean // 上次输入的消息
//播放错误
@State isPlayerError: boolean = false
@State isCanplay: boolean = false
...
...
@@ -71,7 +73,7 @@ export struct DetailPlayVLivePage {
if(!await onlyWifiLoadVideo()){
this.showToastTip(this.toastText)
}
this.c
hatRoomController.configDetail(this.contentDetailData
)
this.c
onfigChatRoom(
)
}
aboutToDisappear(): void {
...
...
@@ -92,6 +94,22 @@ export struct DetailPlayVLivePage {
// WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
configChatRoom() {
this.chatRoomController.onHistoryMessage = (liveRoomItemBean: LiveRoomItemBean) => {
const preDisplay = this.contentDetailData.liveInfo.preCommentFlag == 1
if (this.liveViewModel.filterMySelfCommentNoPreDisplay(liveRoomItemBean, preDisplay)) {
return
}
this.lastInputedComment = liveRoomItemBean
}
this.chatRoomController.onLiveMessage = (liveRoomItemBean: LiveRoomItemBean) => {
if (liveRoomItemBean.optionType == LiveMessageOptType.ZH_ROOM_NUMBER_MSG) {
this.liveRoomDataBean.pv = Number(liveRoomItemBean.pv)
}
}
this.chatRoomController.configDetail(this.contentDetailData)
}
build() {
Stack({ alignContent: Alignment.Top }) {
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/viewModel/LiveViewModel.ets
View file @
1ec4e6e
...
...
@@ -7,10 +7,12 @@ import {
LiveRoomItemBean,
ValueType
} from 'wdBean/Index'
import { LiveMessageIsHistoryMessage } from 'wdBean/src/main/ets/bean/live/LiveRoomBean'
import { SpConstants } from 'wdConstant'
import { ContentDetailRequest } from 'wdDetailPlayApi/Index'
import { Logger } from 'wdKit/Index'
import { Logger
, SPHelper
} from 'wdKit/Index'
import { ToastUtils } from 'wdKit/src/main/ets/utils/ToastUtils'
import { ResponseDTO } from 'wdNetwork/Index'
import {
HttpUtils,
ResponseDTO } from 'wdNetwork/Index'
import { LiveModel } from './LiveModel'
const TAG = "LiveViewModel"
...
...
@@ -196,4 +198,26 @@ export class LiveViewModel {
retItem.fullColumnImgUrlDto = item.fullColumnImgUrlDto
return retItem
}
filterMySelfCommentNoPreDisplay(comment: LiveRoomItemBean, openPreDisplay:boolean) {
let mySelf = false
const userId = HttpUtils.getUserId()
const deviceId = HttpUtils.getDeviceId()
if (comment.senderUserId && comment.senderUserId == userId) {
mySelf = true
} else if (comment.deviceId && comment.deviceId == deviceId) {
mySelf = true
}
let optionType = comment.optionType != undefined ? comment.optionType : comment.dataType
if (mySelf
&& openPreDisplay
&& comment.customFormIM === true
&& LiveMessageIsHistoryMessage(optionType)
) {
return true
}
return false
}
}
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/TabChatComponent.ets
View file @
1ec4e6e
...
...
@@ -53,7 +53,9 @@ export struct TabChatComponent {
this.liveChatList.push(info)
this.pageModel.viewType = ViewType.LOADED;
// this.scroller.scrollEdge(Edge.Bottom)
if (this.pageModel.viewType == ViewType.LOADED) {
this.scroller.scrollEdge(Edge.Bottom)
}
console.log(TAG, '发布评论:', JSON.stringify(this.publishCommentModel.lastCommentModel))
}
}
...
...
@@ -63,6 +65,9 @@ export struct TabChatComponent {
lastInputedCommentChanged(info: string) {
Logger.debug(TAG, "2显示评论》》》: " + JSON.stringify(this.lastInputedComment))
this.liveChatList.push(this.liveViewModel.deepCopyLiveRoomItem(this.lastInputedComment))
if (this.pageModel.viewType == ViewType.LOADED) {
this.scroller.scrollEdge(Edge.Bottom)
}
this.pageModel.viewType = ViewType.LOADED;
}
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/ChartItemComponent.ets
View file @
1ec4e6e
import { LiveRoomItemBean } from 'wdBean/Index'
import { LiveMessageRole } from 'wdBean/src/main/ets/bean/live/LiveRoomBean'
import { LengthMetrics } from '@kit.ArkUI'
@Component
export struct ChatItemComponent {
...
...
@@ -10,17 +12,23 @@ export struct ChatItemComponent {
build() {
Row() {
Text() {
// if (this.item.senderUserName) {
// Span(' 主持人 ')
// .fontSize(11)
// .lineHeight(20)
// .textBackgroundStyle({ color: '#808562', radius: 2 })
// Span(' ')
// }
if (this.item.role == LiveMessageRole.host) {
Span(' 主持人 ')
.fontSize(11)
.lineHeight(20)
.textBackgroundStyle({ color: "#70FFC63F", radius: 2 })
Span(' ')
}
if (this.item.role == LiveMessageRole.guest) {
Span(' 嘉宾 ')
.fontSize(11)
.lineHeight(20)
.textBackgroundStyle({ color: "#70FFC63F", radius: 2 })
Span(' ')
}
Span(this.item.senderUserName + ': ')
.fontColor('#FFFFC63F')
.padding({ right: 118 })
//
Span(this.item.text)
}
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerCommentComponent.ets
View file @
1ec4e6e
import { Action, ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean, LiveRoomItemBean } from 'wdBean/Index'
import { LiveCommentComponent } from 'wdComponent/Index'
import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel'
import { LiveOperRowListView } from 'wdComponent'
import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel'
import { DisplayDirection, SpConstants, ViewType } from 'wdConstant/Index'
...
...
@@ -25,8 +23,8 @@ export struct PlayerCommentComponent {
@Consume displayDirection: DisplayDirection
@State private pageModel: PageModel = new PageModel()
@State liveChatList: Array<LiveRoomItemBean> = []
@Consume @Watch("lastInputedCommentChagned") lastInputedComment: LiveRoomItemBean
@Consume @Watch('liveDetailsBeanChange') contentDetailData: ContentDetailDTO
@Consume publishCommentModel: publishCommentModel
scroller: Scroller = new Scroller()
async aboutToAppear(): Promise<void> {
...
...
@@ -81,6 +79,16 @@ export struct PlayerCommentComponent {
})
}
lastInputedCommentChagned() {
Logger.debug(TAG, "2显示评论》》》: " + JSON.stringify(this.lastInputedComment))
this.liveChatList.push(this.lastInputedComment)
if (this.pageModel.viewType == ViewType.LOADED) {
this.scroller.scrollEdge(Edge.Bottom)
}
this.pageModel.viewType = ViewType.LOADED;
}
build() {
Column() {
Stack({ alignContent: Alignment.BottomStart }) {
...
...
Please
register
or
login
to post a comment