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
陈剑华
2024-06-27 09:53:07 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
c8a055a89e37867429ad44c740c0d07ab4e9ccba
c8a055a8
2 parents
594b8112
e88b7ce5
Merge remote-tracking branch 'origin/main'
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
152 additions
and
40 deletions
sight_harmony/features/wdComponent/src/main/ets/components/page/CardView.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/AudioSuspensionModel.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/video/PlayUIComponent.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
sight_harmony/features/wdPlayer/src/main/ets/controller/WDAliPlayerController.ets
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
sight_harmony/products/phone/src/main/ets/entryability/EntryAbility.ets
sight_harmony/products/phone/src/main/ets/pages/view/AudioComponent.ets
sight_harmony/products/phone/src/main/ets/pages/view/BottomNavigationComponent.ets
sight_harmony/products/phone/src/main/resources/base/media/icon_audio_close.png
sight_harmony/features/wdComponent/src/main/ets/components/page/CardView.ets
View file @
c8a055a
...
...
@@ -441,7 +441,7 @@ export struct PaperSingleColumn999CardView {
Stack({ alignContent: Alignment.BottomEnd }) {
Image(this.item?.coverUrl)
.borderRadius(5)
.objectFit(ImageFit.
Fill
)
.objectFit(ImageFit.
Cover
)
.aspectRatio(16 / 10) ///图片设计比例
.padding({ top: 10 })
//视频
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/AudioSuspensionModel.ets
View file @
c8a055a
...
...
@@ -14,9 +14,6 @@ export class AudioSuspensionModel {
public floatWindowClass: SubscribedAbstractProperty<window.Window> = AppStorage.link<window.Window>('floatWindowClass')
public srcTitle: string = ''
private url: string = ''
private expandWidth: number = vp2px(243)
private expandHeight: number = vp2px(60)
private initMoveX = vp2px(12)
// 窗口是否最小化
private isMinimize: SubscribedAbstractProperty<boolean> = AppStorage.link<boolean>('isMinimize')
constructor() {
...
...
@@ -51,8 +48,10 @@ export class AudioSuspensionModel {
if (this.isMinimize?.get()) {
EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_EXPAND, 1)
AppStorage.setOrCreate('isMinimize', false);
this.playerController.get().resetPlay()
} else {
this.playerController.get().switchPlayOrPause()
}
this.playerController.get().switchPlayOrPause()
} else {
this.url = url
this.playerController.get().firstPlay(url)
...
...
@@ -100,16 +99,6 @@ export class AudioSuspensionModel {
console.info(TAG, 'floatWindowClass Succeeded in changing the window size.');
});
}
public moveWindow(y: number) {
this.floatWindowClass.get().moveWindowTo(this.initMoveX, vp2px(y), (err: BusinessError) => {
let errCode: number = err.code;
if (errCode) {
console.error('floatWindowClass Failed to move the window. Cause:' + JSON.stringify(err));
return;
}
console.info('floatWindowClass Succeeded in moving the window.');
});
}
// 隐藏悬浮窗
public minimize() {
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/video/PlayUIComponent.ets
View file @
c8a055a
...
...
@@ -7,12 +7,15 @@ import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index';
import { DisplayDirection } from 'wdConstant/Index';
import { LiveFollowComponent, LottieView } from 'wdComponent/Index';
import { WDShare } from 'wdShare/Index';
import { faceDetector } from '@kit.CoreVisionKit';
//直播间播放器上层覆盖物
@Component
export struct PlayUIComponent {
playerController?: WDAliPlayerController;
//菜单键是否可见
@State @Watch('onChangeMenuVisible') isMenuVisible: boolean = true
private ispause:boolean = false
@Consume contentDetailData: ContentDetailDTO
@Consume liveRoomDataBean: LiveRoomDataBean
@State currentTime: string = ''
...
...
@@ -35,8 +38,11 @@ export struct PlayUIComponent {
let time: number = 0
if (this.isMenuVisible) {
setTimeout(() => {
if(this.ispause){
return
}
this.isMenuVisible = false
},
5
* 1000)
},
4
* 1000)
} else {
clearTimeout(time)
}
...
...
@@ -46,6 +52,16 @@ export struct PlayUIComponent {
this.onChangeMenuVisible()
this.initPlayerSet()
if(this.playerController){
this.playerController.onStatusChangeForPlayUIComponent = (status: number) => {
if(1 == status){
this.ispause = false
this.isMenuVisible = false
}else if(2 == status){
this.ispause = true
}
}
}
}
aboutToDisappear(): void {
...
...
@@ -234,7 +250,7 @@ export struct PlayUIComponent {
//回看
else if (this.contentDetailData.liveInfo?.liveState == 'end') {
Row() {
Text('回看')
Text(
StringUtils.isEmpty(this.liveUrl)?'已结束':
'回看')
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
...
...
@@ -271,6 +287,9 @@ export struct PlayUIComponent {
if (this.contentDetailData?.liveInfo?.liveState === 'wait') {
return
}
if(this.ispause){
return
}
this.isMenuVisible = !this.isMenuVisible
})
}
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
View file @
c8a055a
...
...
@@ -10,6 +10,8 @@ import { window } from '@kit.ArkUI';
import { EmptyComponent } from 'wdComponent/Index';
import { DateTimeUtils } from 'wdKit/Index';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
import { AudioSuspensionModel } from 'wdComponent'
import { BusinessError } from '@kit.BasicServicesKit';
const storage = LocalStorage.getShared();
const TAG = 'DetailVideoListPage'
...
...
@@ -42,6 +44,8 @@ export struct DetailVideoListPage {
pageHideTime:number = 0;
@Provide onlyWifiLoadVideo: boolean = false
@Provide toastTextVisible: boolean = false
private AudioSuspension = new AudioSuspensionModel()
@State isShowAudioCom: boolean = false
async aboutToAppear(): Promise<void> {
// 注册监听网络连接
...
...
@@ -80,6 +84,21 @@ export struct DetailVideoListPage {
this.openFullScreen()
this.pageShowTime = DateTimeUtils.getTimeStamp()
// 判断当前窗口是否已显示,使用callback异步回调。
this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));
return;
}
console.info(TAG, 'window is showing: ' + JSON.stringify(data));
if(data) {
this.isShowAudioCom = true
this.AudioSuspension.playerController.get()?.pause();
this.AudioSuspension.minimize()
}
});
}
onPageHide(): void {
...
...
@@ -91,6 +110,13 @@ export struct DetailVideoListPage {
let duration = 0
duration = Math.floor((this.pageHideTime - this.pageShowTime)/1000)
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration)
console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom);
if (this.isShowAudioCom) {
this.AudioSuspension.showWindow()
this.AudioSuspension.playerController.get()?.play();
this.isShowAudioCom = false
}
}
/**
...
...
sight_harmony/features/wdPlayer/src/main/ets/controller/WDAliPlayerController.ets
View file @
c8a055a
...
...
@@ -60,6 +60,7 @@ export class WDAliPlayerController {
// 准备完成,决定是否播放回调。如果不实现,则自动播放
public onCanplay?: () => void;
public onStatusChange?: (status: number) => void;
public onStatusChangeForPlayUIComponent?: (status: number) => void;
public onFirstFrameDisplay?: () => void
// 埋点字段
private creatStartTime: number = 0; //开始加载时间
...
...
@@ -513,6 +514,9 @@ export class WDAliPlayerController {
if (this.onStatusChange) {
this.onStatusChange(this.status)
}
if(this.onStatusChangeForPlayUIComponent){
this.onStatusChangeForPlayUIComponent(this.status)
}
}
...
...
sight_harmony/features/wdPlayer/src/main/ets/controller/WDPlayerController.ets
View file @
c8a055a
...
...
@@ -360,6 +360,12 @@ export class WDPlayerController {
// this.progressThis.progressVal = 0;
}
resetPlay() {
this.duration = 0;
this.url = this.avPlayer?.url || '';
this.avPlayer?.reset();
}
onVolumeActionStart(event: GestureEvent) {
this.positionY = event.offsetY;
}
...
...
sight_harmony/products/phone/src/main/ets/entryability/EntryAbility.ets
View file @
c8a055a
...
...
@@ -107,8 +107,18 @@ export default class EntryAbility extends UIAbility {
;
});
floatWindowClass.on('windowEvent', (data) => {
EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_TYPE, data)
floatWindowClass.setWindowFocusable(false, (err: BusinessError) => {
const errCode: number = err.code;
if (errCode) {
console.error(`Failed to set the window to be focusable. Cause code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in setting the window to be focusable.');
});
floatWindowClass.on('touchOutside', () => {
console.info('touchOutside');
EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_TYPE, 3)
});
});
...
...
sight_harmony/products/phone/src/main/ets/pages/view/AudioComponent.ets
View file @
c8a055a
...
...
@@ -7,6 +7,11 @@ import { LottieView } from 'wdComponent/Index'
const TAG = 'AudioSuspensionModel'
interface Position {
x: number,
y: number
}
@Entry
@Component
struct Index {
...
...
@@ -17,17 +22,21 @@ struct Index {
@State progressVal: number = 0;
@State currentStatus: number | string |undefined = 0;
@State isExpand: boolean = true;
@State moveY: number = 604;
private expandWidth: number = vp2px(243)
private expandHeight: number = vp2px(60)
private foldWidth: number = vp2px(60)
private foldHeight: number = vp2px(60)
bottomSafeHeight: number = 720 // 悬浮窗底部滑动限制
topSafeHeight: number = 94 // 悬浮窗顶部滑动限制
bottomSafeHeight: number = vp2px(720) // 悬浮窗底部滑动限制
topSafeHeight: number = vp2px(94) // 悬浮窗顶部滑动限制
@State name: string = 'audio_status_wait';
@State @Watch("moveWindow") windowPosition: Position = { x: vp2px(12), y: vp2px(576) };
private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.All });
private subWindow:window.Window | null = null
async aboutToAppear() {
window.findWindow("subWindow").setWindowBackgroundColor("#00000000")
this.subWindow = window.findWindow("subWindow")
this.subWindow.setWindowBackgroundColor("#00000000")
this.AudioSuspension.playerController.get().onTimeUpdate = (position, duration) => {
this.currentTime = DateFormatUtil.convertMillisecondsToMinutesSeconds(position);
this.totalTime = DateFormatUtil.convertMillisecondsToMinutesSeconds(duration);
...
...
@@ -69,6 +78,14 @@ struct Index {
}
moveWindow() {
if (this.subWindow == null) {
console.info('Faild in destroying the window.');
} else {
this.subWindow.moveWindowTo(this.windowPosition.x, this.windowPosition.y);
}
}
onPageHide() {
// this.status = PlayerConstants.STATUS_PAUSE;
this.AudioSuspension.playerController.get()?.pause();
...
...
@@ -126,8 +143,14 @@ struct Index {
.height(3)
.margin({ top: 7 })
}
.width("100%")
.height("100%")
.padding({
top: 10,
bottom: 10,
left: 10,
right: 0
})
.width(243)
.height(60)
.justifyContent(FlexAlign.Start)
Row() {
...
...
@@ -145,8 +168,8 @@ struct Index {
}))
Image($r("app.media.icon_audio_close"))
.objectFit(ImageFit.Contain)
.width(24)
.height(24)
.width(32)
.height(32)
.gesture(
TapGesture()
.onAction((event: GestureEvent) => {
...
...
@@ -183,21 +206,23 @@ struct Index {
this.isExpand = true
this.AudioSuspension.resizeWindow(this.expandWidth, this.expandHeight)
}),
PanGesture({
fingers: 1,
direction: PanDirection.Vertical,
distance: 0
})
PanGesture(this.panOption)
//手势识别成功回调。
.onActionStart((event: GestureEvent) => {
console.info('Pan start');
})
// 手势移动过程中回调。发生拖拽时,获取到触摸点的位置,并将位置信息传递给windowPosition
.onActionUpdate((event: GestureEvent) => {
let newY = Math.ceil(this.moveY + event.offsetY);
this.moveY = Math.min(Math.max(newY, this.topSafeHeight), this.bottomSafeHeight);
// console.log(TAG,'this.moveY', this.moveY)
this.AudioSuspension.moveWindow(this.moveY)
// this.windowPosition.x += event.offsetX;
let newY = this.windowPosition.y + event.offsetY;
this.windowPosition.y = Math.min(Math.max(newY, this.topSafeHeight), this.bottomSafeHeight);
})
//手势识别成功,手指抬起后触发回调。
.onActionEnd(() => {
console.info('Pan end');
})
)
)
.width('100%')
.height('100%')
.borderRadius(4)
.padding({
top: 10,
...
...
sight_harmony/products/phone/src/main/ets/pages/view/BottomNavigationComponent.ets
View file @
c8a055a
...
...
@@ -9,6 +9,8 @@ import { VideoChannelPage } from './VideoChannelPage';
import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel';
import { ALL, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife';
import { ParamType, Tracking } from 'wdTracking/Index';
import { AudioSuspensionModel } from 'wdComponent'
import { BusinessError } from '@kit.BasicServicesKit';
const TAG = 'BottomNavigationComponent';
PersistentStorage.persistProp('channelIds', '');
...
...
@@ -52,6 +54,8 @@ export struct BottomNavigationComponent {
@State assignChannel: AssignChannelParam = new AssignChannelParam()
// 自动刷新触发(双击tab自动刷新)
@State autoRefresh: number = 0
private AudioSuspension = new AudioSuspensionModel()
@State isShowAudioCom: boolean = false
async aboutToAppear() {
...
...
@@ -143,6 +147,9 @@ export struct BottomNavigationComponent {
.hoverEffect(HoverEffect.Highlight)
.visibility(this.displayDirection === DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
// .hitTestBehavior(HitTestMode.Block)
.onTouch(() => {
this.handleAudio(navItem)
})
.onClick(() => {
Logger.info(TAG, `onChange, index: ${index}`);
Logger.info(TAG, `onChange, navItem: ${JSON.stringify(navItem)}`);
...
...
@@ -152,7 +159,6 @@ export struct BottomNavigationComponent {
"pageId": navItem.id,
}
Tracking.event("bar_click", params)
this.onBottomNavigationIndexChange(navItem, index)
})
...
...
@@ -221,9 +227,37 @@ export struct BottomNavigationComponent {
return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no')
}
// 控制音频悬浮窗显隐
handleAudio(navItem: BottomNavDTO) {
if (navItem.name === '视频') {
// 判断当前窗口是否已显示,使用callback异步回调。
this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));
return;
}
console.info(TAG, 'window is showing: ' + JSON.stringify(data));
if(data) {
this.isShowAudioCom = true
this.AudioSuspension.playerController.get()?.pause();
this.AudioSuspension.minimize()
}
});
} else {
console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom);
if (this.isShowAudioCom) {
this.AudioSuspension.showWindow()
this.AudioSuspension.playerController.get()?.play();
this.isShowAudioCom = false
}
}
}
// 底导切换函数
async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) {
Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`);
if (navItem.name === '我的') {
this.barBackgroundColor = Color.White
this.currentBottomNavInfo = {} as BottomNavDTO
...
...
@@ -237,7 +271,6 @@ export struct BottomNavigationComponent {
}
}
this.currentNavIndex = index;
// 请求顶导数据(参数):
}
...
...
sight_harmony/products/phone/src/main/resources/base/media/icon_audio_close.png
View file @
c8a055a
410 Bytes
|
W:
|
H:
872 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
Please
register
or
login
to post a comment