王士厅
... ... @@ -89,18 +89,19 @@ export struct Card6Component {
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5') ? 35 :
0 )
}.alignContent(Alignment.TopStart)
// .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 60: 156)
}
.justifyContent(FlexAlign.Start)
Blank()
//bottom 评论等信息
CardSourceInfo({ compDTO: this.compDTO, contentDTO: this.contentDTO })
}
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Start)
.width('64%')
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 78 : 156)
Stack({alignContent: Alignment.BottomEnd}) {
Image(this.loadImg ? this.contentDTO.coverUrl || this.contentDTO.fullColumnImgUrls?.[0]?.url || this.contentDTO.fullColumnImgUrls?.[0]?.fullUrl : '')
... ... @@ -110,6 +111,7 @@ export struct Card6Component {
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 78 : 156)
CardMediaInfo({ contentDTO: this.contentDTO })
}
}
.onClick((event: ClickEvent) => {
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
... ... @@ -123,6 +125,7 @@ export struct Card6Component {
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.width(CommonConstants.FULL_WIDTH)
// .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 107 : 217)
.justifyContent(FlexAlign.SpaceBetween)
... ...
... ... @@ -3,7 +3,7 @@ import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'
import { WDRouterRule } from 'wdRouter/Index'
import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'
import { Logger } from 'wdKit';
import { window } from '@kit.ArkUI';
import { font, window } from '@kit.ArkUI';
/**
* 读报纸半屏弹窗
... ... @@ -56,6 +56,11 @@ export struct ENewspaperListDialog {
}
async aboutToAppear() {
//注册字体
font.registerFont({
familyName: 'BebasNeueBold',
familySrc: $rawfile('font/BebasNeueBold.otf')
})
// 屏幕高度 - 滑动高度计算
let windowClass: window.Window = await window.getLastWindow(getContext(this));
let changeHeight = 85 + 44 + px2vp(windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height)
... ... @@ -151,7 +156,7 @@ export struct ENewspaperListDialog {
Column() {
if (itemIndex == 0) {
Text(item.pageNum + '版:' + item.pageName)
.fontSize($r('app.float.font_size_14'))
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_ED2800'))
.fontWeight(600)
.width('100%')
... ... @@ -165,7 +170,7 @@ export struct ENewspaperListDialog {
Column() {
if (positionItem.shortTitle) {
Text(positionItem.shortTitle)
.fontSize($r('app.float.font_size_14'))
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
// .maxLines(2)
... ... @@ -176,7 +181,7 @@ export struct ENewspaperListDialog {
if (positionItem.title) {
Text(positionItem.title)
.fontSize($r('app.float.font_size_17'))
.fontSize($r('app.float.font_size_16'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.margin({
... ... @@ -187,7 +192,7 @@ export struct ENewspaperListDialog {
if (positionItem.downTitle) {
Text(positionItem.downTitle)
.fontSize($r('app.float.font_size_14'))
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.margin({
... ... @@ -197,7 +202,7 @@ export struct ENewspaperListDialog {
}
if (positionItem.newsTxt) {
Text(positionItem.newsTxt)
.fontSize($r('app.float.font_size_14'))
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_999999'))
.lineHeight(25)
.margin({
... ...
import { NetworkUtil, SPHelper } from 'wdKit';
import { SpConstants } from 'wdConstant';
async function onlyWifiLoadImg() : Promise<boolean> {
async function onlyWifiLoadImg(): Promise<boolean> {
let loadImageOnlyWifiSwitch = await SPHelper.default.get(SpConstants.SETTING_WIFI_IMAGE_SWITCH, '') || false;
let isNetConnected = NetworkUtil.isNetConnected();
if (!loadImageOnlyWifiSwitch) {
// 开关没开,直接让加载图片
return true
}
let netWorkStatus = NetworkUtil.getNetworkType();
if (isNetConnected) {
// 开关打开,wifi下才加载图片
if (netWorkStatus === NetworkUtil.TYPE_WIFI) {
return true;
} else {
if (loadImageOnlyWifiSwitch) {
return false
} else {
return true;
}
}
} else {
return false;
return true
}
return false
}
export { onlyWifiLoadImg }
\ No newline at end of file
... ...
... ... @@ -16,7 +16,7 @@ import { CommentDialogView } from '../view/CommentDialogView';
import { window } from '@kit.ArkUI';
import { PlayerFullScreenView } from '../view/PlayerFullScreenView';
import { OperRowListView, publishCommentModel } from 'wdComponent/Index';
import {ParamType,TrackConstants } from 'wdTracking/Index';
const TAG = 'DetailPlayShortVideoPage';
/**
... ... @@ -49,6 +49,8 @@ export struct DetailPlayShortVideoPage {
@Consume showComment: boolean // 是否显示底部评论,首页视频频道传false
@State imageVisible: boolean = true
@State ratio: number = 16 / 9
pageParam: ParamType = {}
PageName: string = ''
/**
* 页面显示重查用户关注、点赞等信息
... ... @@ -91,7 +93,7 @@ export struct DetailPlayShortVideoPage {
} else {
this.queryNewsInfoOfUser()
if (!this.playerController.getPlayer()) {
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '');
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '',this.PageName,this.PageName,this.pageParam);
} else {
await this.playerController.play()
this.imageVisible = false
... ... @@ -165,9 +167,30 @@ export struct DetailPlayShortVideoPage {
}
this.queryNewsInfoOfUser()
this.contentTrackingDict()
}
contentTrackingDict(){
this.pageParam = {
'contentType': `${this.contentDetailData.newsType}`,
'contentId': `${this.contentDetailData.newsId}`,
'contentName': `${this.contentDetailData.newsTitle || ''}`,
}
if(this.contentDetailData.newsType == 1) {
this.PageName = TrackConstants.PageName.VideoDetail // 点播
} else if(this.contentDetailData.newsType == 2) {
this.PageName = TrackConstants.PageName.Live_Detail // 直播
} else if(this.contentDetailData.newsType == 5) {
this.PageName = TrackConstants.PageName.Summary_Detail // 专题详情页
} else if(this.contentDetailData.newsType == 8) {
this.PageName = TrackConstants.PageName.Article_Detail // 图文详情页
} else if(this.contentDetailData.newsType == 9) {
this.PageName = TrackConstants.PageName.Atlas_Detail // 图集详情页
} else if(this.contentDetailData.newsType == 14 || this.contentDetailData.newsType == 15) {
this.PageName = TrackConstants.PageName.DynamicDetail // 动态图文/动态视频
}
console.log('视频详情页',JSON.stringify(this.pageParam))
console.log('视频详情页2',JSON.stringify(this.PageName))
}
async aboutToDisappear(): Promise<void> {
console.log(TAG, 'aboutToDisappear', this.index)
await this.playerController?.pause()
... ... @@ -251,7 +274,7 @@ export struct DetailPlayShortVideoPage {
playerController: this.playerController,
onLoad: async () => {
if (this.contentDetailData != null && this.contentDetailData?.videoInfo[0] != null) {
this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl);
this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl,this.PageName,this.PageName,this.pageParam);
}
}
})
... ...
... ... @@ -38,9 +38,8 @@ export struct PlayerRightView {
@Consume showCommentList: boolean
@Consume displayDirection: DisplayDirection
@Consume publishCommentModel: publishCommentModel
// @State likesStyle: number | string = 1 // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
@State likesStyle: number | string = 1 // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
@State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以
@State likesStyle: number | string = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
pageParam: ParamType = {}
PageName: string = ''
followUserId: string = ''
... ...
... ... @@ -8,6 +8,8 @@
"version": "1.0.0",
"dependencies": {
"wdKit": "file:../../commons/wdKit",
"premierlibrary": "file:./libs/premierlibrary.har"
"premierlibrary": "file:./libs/premierlibrary.har",
"wdTracking": "file:../wdTracking",
"wdBean": "file:../../features/wdBean"
}
}
... ...
... ... @@ -3,6 +3,9 @@ import prompt from '@ohos.promptAction';
import { Logger } from '../utils/Logger';
import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
import { BusinessError } from '@ohos.base';
import { TrackingPlay } from 'wdTracking/Index';
import { ParamType } from 'wdTracking/Index';
import { DateTimeUtils } from 'wdKit/Index';
@Observed
export class WDPlayerController {
... ... @@ -17,6 +20,12 @@ export class WDPlayerController {
private seekTime: number = 0;
private positionY: number = 0;
private startTime: number = 0;
private pageParam: ParamType = {}
private pageName: string = ''
private creatStartTime:number = 0;//开始加载时间
private creatEndTime:number = 0;//加载完成时间
private prepareTime:number = 0; //加载时间
private currentPlayTime:number = 0; //当前播放时间
public onVideoSizeChange?: (width: number, height: number) => void;
public onTimeUpdate?: (position: number, duration: number) => void;
public onVolumeUpdate?: (volume: number) => void;
... ... @@ -28,6 +37,9 @@ export class WDPlayerController {
public videoWidth: number = 0
public videoHeight: number = 0
constructor() {
Logger.error("初始化")
this.initPromise = this.createAVPlayer();
... ... @@ -123,6 +135,8 @@ export class WDPlayerController {
});
this.avPlayer?.on(Events.ERROR, (error) => {
this.playError(error.message);
console.log('播放错误',JSON.stringify(error))
TrackingPlay.videoPlayError(error.message, this.pageName, this.pageName, this.pageParam)
})
this.avPlayer?.on('seekDone', (time: number) => {
this.initProgress(time);
... ... @@ -148,8 +162,18 @@ export class WDPlayerController {
this.surfaceId = surfaceId
}
async firstPlay(url: string) {
async firstPlay(url: string,pageId?: string, pageName?: string, pageParam?: ParamType) {
this.url = url;
//加载时长prepareTime
this.creatStartTime = DateTimeUtils.getTimeStamp()
console.log('开始创建',JSON.stringify(this.creatStartTime))
this.prepareTime = 0
if(pageName){
this.pageName = pageName
}
if(pageParam){
this.pageParam = pageParam
}
if (this.avPlayer == null) {
Logger.error("等待")
await this.initPromise;
... ... @@ -166,6 +190,11 @@ export class WDPlayerController {
}
Logger.error("开始播放", this.url)
this.avPlayer.url = this.url;
//加载时长prepareTime
this.creatEndTime = DateTimeUtils.getTimeStamp()
this.prepareTime = 0
this.prepareTime = Math.floor((this.creatEndTime - this.creatStartTime)/1000)
console.log('开始播放2',JSON.stringify(this.prepareTime))
}
async release() {
... ... @@ -271,6 +300,7 @@ export class WDPlayerController {
}
if (mode === SliderChangeMode.End) {
this.seekTime = Math.floor(value * this.duration / 100);
this.currentPlayTime = this.seekTime
this.avPlayer?.seek(this.seekTime);
}
}
... ... @@ -288,6 +318,7 @@ export class WDPlayerController {
}
initProgress(time: number) {
this.currentPlayTime=Math.floor(time / 1000);
let nowSeconds = Math.floor(time / 1000);
let totalSeconds = Math.floor(this.duration / 1000);
if (this.onTimeUpdate) {
... ... @@ -357,6 +388,24 @@ export class WDPlayerController {
watchStatus() {
console.log('watchStatus', this.status)
if(this.status == 1){
console.log('播放视频')
console.log('播放视频prepareTime',JSON.stringify(this.prepareTime))
console.log('播放视频pageName',JSON.stringify(this.pageName))
console.log('播放视频pageParam',JSON.stringify(this.pageParam))
// 播放埋点
TrackingPlay.videoPositivePlay(Number(this.prepareTime),this.pageName, this.pageName, this.pageParam)
}
if(this.status == 2){
let initDuration = Math.floor(Number(this.duration)/1000)
console.log('播放结束')
console.log('播放结束currentPlayTime',JSON.stringify(this.currentPlayTime))
console.log('播放结束initDuration',JSON.stringify(initDuration))
console.log('播放结束pageName',JSON.stringify(this.pageName))
console.log('播放结束pageParam',JSON.stringify(this.pageParam))
// 播放结束埋点
TrackingPlay.videoPlayEnd(this.currentPlayTime, initDuration, this.currentPlayTime, this.pageName, this.pageName, this.pageParam)
}
if (this.onStatusChange) {
this.onStatusChange(this.status)
}
... ...
... ... @@ -25,7 +25,7 @@ export class TrackingPlay {
Tracking.event("video_positive_pybk", params)
}
// 视频 播放结束
// 视频 播放结束 currentPlayTime:当前时长,totalTime:总时长 ,browseTime:浏览时长,
static videoPlayEnd(currentPlayTime: number, totalTime: number, browseTime: number, pageId: string, pageName: string, extParams: ParamType) {
let params = TrackingUtils.generateParams(extParams)
if (pageId.length) {
... ...
... ... @@ -13,7 +13,8 @@
"@ohos/pulltorefresh": "^2.0.5",
"@mpaas/udid": "0.0.2",
"@mpaas/upgrade": "0.0.2",
"@mpaas/framework": "0.0.2"
"@mpaas/framework": "0.0.2",
"@ohos/imageknife": "^2.1.2"
},
"dynamicDependencies": {}
}
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@ import { MinePageComponent } from 'wdComponent/src/main/ets/components/page/Mine
import { CompUtils, TopNavigationComponent, TopNavigationComponentNew } from 'wdComponent/Index';
import { VideoChannelPage } from './VideoChannelPage';
import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel';
import { ImageKnifeComponent, ImageKnifeOption, NONE } from '@ohos/imageknife';
const TAG = 'BottomNavigationComponent';
PersistentStorage.persistProp('channelIds', '');
... ... @@ -134,16 +135,26 @@ export struct BottomNavigationComponent {
@Builder
tabBarBuilder(navItem: BottomNavDTO, index: number) {
Stack({ alignContent: Alignment.Bottom }) {
Image(this.getBottomIcon(navItem, this.currentNavIndex === index))
.height(CommonConstants.FULL_PARENT)
// Image(this.getBottomIcon(navItem, this.currentNavIndex === index))
// .height(CommonConstants.FULL_PARENT)
// .padding({
// bottom: 15,
// left: 10,
// right: 10,
// top: 2
// })
// .aspectRatio(this.ASPECT_RATIO_1_1)
// .alt(this.getBottomLocalIcon(navItem, this.currentNavIndex === index))
ImageKnifeComponent({ imageKnifeOption: this.getBottomImageKnifeOption(navItem, this.currentNavIndex === index) })
.padding({
bottom: 15,
left: 10,
right: 10,
top: 2
})
.aspectRatio(this.ASPECT_RATIO_1_1)
.alt(this.getBottomLocalIcon(navItem, this.currentNavIndex === index))
.width('100%')
.height('100%')
.enabled(false)
Text(navItem.name)
.margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') })
... ... @@ -157,6 +168,7 @@ export struct BottomNavigationComponent {
.height($r('app.float.bottom_navigation_barHeight'))
.hoverEffect(HoverEffect.Highlight)
.visibility(this.displayDirection === DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
// .hitTestBehavior(HitTestMode.Block)
.onClick(() => {
Logger.info(TAG, `onChange, index: ${index}`);
this.onBottomNavigationIndexChange(navItem, index)
... ... @@ -164,6 +176,24 @@ export struct BottomNavigationComponent {
}
getBottomImageKnifeOption(navItem: BottomNavDTO, isSelect: boolean): ImageKnifeOption {
let defaultIcon = this.getBottomLocalIcon(navItem, isSelect)
let url = this.getBottomIcon(navItem, isSelect)
let imageKnifeOption: ImageKnifeOption = {
loadSrc: url,
// 占位图使用本地资源
placeholderSrc: defaultIcon,
// 失败占位图使用本地资源
errorholderSrc: defaultIcon,
// 是否开启一级内存缓存
isCacheable: true,
// 磁盘缓存none
strategy: new NONE()
};
return imageKnifeOption
}
private getBottomIcon(navItem: BottomNavDTO, isSelect: boolean): string | Resource {
if (!navItem) {
return ''
... ... @@ -176,10 +206,10 @@ export struct BottomNavigationComponent {
// 获取常规icon
icon = isSelect ? navItem.iconC : navItem.icon
}
if (StringUtils.isEmpty(icon) || icon.includes('.pag')) {
// 兜底,获取预置的本地icon
return this.getBottomLocalIcon(navItem, isSelect)
}
// if (StringUtils.isEmpty(icon) || icon.includes('.pag')) {
// // 兜底,获取预置的本地icon
// return this.getBottomLocalIcon(navItem, isSelect)
// }
return icon
}
... ...
... ... @@ -17,6 +17,7 @@ import { TrackingModule } from 'wdTracking/Index'
import { JSON } from '@kit.ArkTS'
import app from '@system.app'
import { GetuiPush, HWLocationUtils } from 'wdHwAbility/Index'
import { ImageKnife, ImageKnifeGlobal } from '@ohos/imageknife'
const TAG = "[StartupManager]"
... ... @@ -58,6 +59,14 @@ export class StartupManager {
HostManager.changeHost(spHostUrl as HostEnum)
}
// 初始化全局ImageKnife
ImageKnife.with(this.context);
let imageKnife: ImageKnife | undefined = ImageKnifeGlobal.getInstance().getImageKnife()
if (imageKnife != undefined) {
//设置全局内存缓存大小张数
imageKnife.setLruCacheSize(100, 100 * 1204 * 1024)
}
// 友盟预初始化
this.preInitUmentStat()
... ...