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-26 17:14:42 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
06df6531481a6e4da003cb9c1f8d821448a9c46a
06df6531
1 parent
b962bfa2
音频悬浮窗相关问题
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
27 deletions
sight_harmony/features/wdComponent/src/main/ets/viewmodel/AudioSuspensionModel.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.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/viewmodel/AudioSuspensionModel.ets
View file @
06df653
...
...
@@ -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() {
...
...
@@ -100,16 +97,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/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
View file @
06df653
...
...
@@ -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/products/phone/src/main/ets/pages/view/AudioComponent.ets
View file @
06df653
...
...
@@ -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();
...
...
@@ -183,16 +200,20 @@ 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');
})
)
)
...
...
sight_harmony/products/phone/src/main/ets/pages/view/BottomNavigationComponent.ets
View file @
06df653
...
...
@@ -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 @
06df653
410 Bytes
|
W:
|
H:
927 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
Please
register
or
login
to post a comment