Skip to content

Commit

Permalink
Merge branch 'main' into new-offical-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghaifeng2 committed Sep 13, 2023
2 parents 56ffc4a + f2c226e commit 9b63d98
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/yyeva/README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let player:YYEvaType = await yyEva({
})
player.start() // start player
player.stop() // pause player
player.destory() // dstory player
player.destroy() // destroy player
```
## configuration
| options | effect | defaults |required|
Expand Down Expand Up @@ -79,4 +79,4 @@ WeChat ios has been verified and can be played automatically
WeChat Android needs to be manually clicked or customized according to the `onRequestClickPlay` event

### Wechat Miniprogram
[NPM Package](https://www.npmjs.com/package/yyeva-wechat)
[NPM Package](https://www.npmjs.com/package/yyeva-wechat)
2 changes: 1 addition & 1 deletion packages/yyeva/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let player:YYEvaType = await yyEva({
})
player.start() // start player
player.stop() // pause player
player.destory() // dstory player
player.destroy() // destroy player
```
## 配置
| 选项 | 作用 | 默认值 |必填|
Expand Down
2 changes: 1 addition & 1 deletion packages/yyeva/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yyeva",
"version": "1.0.0-rc.21",
"version": "1.0.0-rc.23",
"description": "mp4 gift player",
"files": [
"dist",
Expand Down
10 changes: 5 additions & 5 deletions packages/yyeva/src/player/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ export default class EVideo {
this.isPlay = isPlay
}
}
private isDestoryed() {
logger.debug('player is destoryed!')
private isDestroyed() {
logger.debug('player is destroyed!')
}
public start() {
//::TODO 做播放兼容性处理
if (!this.renderer) return this.isDestoryed()
if (!this.renderer) return this.isDestroyed()
this.startEvent()
}

Expand Down Expand Up @@ -291,7 +291,7 @@ export default class EVideo {
}
public stop() {
logger.debug('[player]stop.')
if (!this.renderer) return this.isDestoryed()
if (!this.renderer) return this.isDestroyed()
if (this.renderer.isPlay === false) return
this.setPlay(false)
this.animator.stop()
Expand Down Expand Up @@ -536,7 +536,7 @@ export default class EVideo {
return URL.createObjectURL(blob)
}
public destroy() {
if (!this.renderer) return this.isDestoryed()
if (!this.renderer) return this.isDestroyed()
this.revokeObjectURL('destroy')
logger.debug('[destroy]')
// this.stop()
Expand Down
2 changes: 1 addition & 1 deletion packages/yyeva/src/player/render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class WglRender {
public destroy() {
this.webgl.destroy()
this.videoEntity.destroy()
this.renderCache.destory()
this.renderCache.destroy()
}

// public render(nextFPS: number) {
Expand Down
4 changes: 2 additions & 2 deletions packages/yyeva/src/player/render/mCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export default class MCache {
this.checkCache()
this.setAnimationStatus()
}
public destory() {
logger.debug('[mCache]', '[destory]')
public destroy() {
logger.debug('[mCache]', '[destroy]')
this.removeCache()
this.checkCache()
}
Expand Down
4 changes: 2 additions & 2 deletions packages/yyeva/src/player/render/renderCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class RenderCache {
/**
* 注销缓存
*/
public destory() {
this.mCache.destory()
public destroy() {
this.mCache.destroy()
}
/**
* 申请缓存
Expand Down
24 changes: 22 additions & 2 deletions packages/yyeva/src/player/render/videoEntity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {logger} from 'src/helper/logger'
import {isAndroid, isIOS} from 'src/helper/polyfill'
import {isDataUrl, isOffscreenCanvasSupported} from 'src/helper/utils'
import Animator from 'src/player/video/animator'
import {MixEvideoOptions, VideoAnimateType, VideoAnimateEffectType, VideoDataType, EScaleMode} from 'src/type/mix'
Expand Down Expand Up @@ -375,14 +376,31 @@ export default class VideoEntity {
return text
}

private defaultFontInfo(fontSize: number, ctx: ContextType) {
// console.log('font=', ctx.font)
if (isAndroid) {
let familyName = 'sans-serif'
const originFont = ctx.font.split(' ')
if (originFont && originFont.length) {
familyName = originFont[originFont.length - 1]
}

return ['normal', `${Math.round(fontSize)}px`, familyName]
} else if (isIOS) {
return ['normal', `${Math.round(fontSize)}px`, 'SFUI-Heavy']
} else {
return ['600', `${Math.round(fontSize)}px`, 'Microsoft YaHei']
}
}

/**
* 文字转换图片
* @param item
*/
private async makeTextImg(item: VideoAnimateEffectType, eOptions: any = {}, width = 0) {
if (!this.ctx) return
const ctx = this.ctx
// console.log(`[makeTextImg] eOptions:`, eOptions)
console.log(`[makeTextImg] eOptions:`, eOptions)
if (eOptions.fontStyle) item.fontStyle = eOptions.fontStyle
if (eOptions.fontColor) item.fontColor = eOptions.fontColor
if (eOptions.fontSize) item.fontSize = eOptions.fontSize
Expand Down Expand Up @@ -413,7 +431,9 @@ export default class VideoEntity {
fontSize = Math.min((w / txtlength) * 1, defaultFontSize)
}

const font = ['600', `${Math.round(fontSize)}px`, 'Microsoft YaHei']
const font = this.defaultFontInfo(fontSize, ctx)
// console.log('@@@@font=', font)
// const font = ['600', `${Math.round(fontSize)}px`, 'Microsoft YaHei']
if (fontStyle === 'b') {
font.unshift('bold')
}
Expand Down
10 changes: 9 additions & 1 deletion projects/offical/src/preview/config/video.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@

const queryString = window.location.search;
console.log('[video]queryString=', queryString)
const urlParams = new URLSearchParams(queryString)
export const videoUrl = urlParams.get('videoUrl')

console.log('[video]videoUrl=', videoUrl);

const host = ''
const selected: any = {
default: {
Expand All @@ -8,7 +16,7 @@ const selected: any = {
anchor_nick: 'boy',
anchor_avatar: '/yy/2.jpeg',
}, */
videoUrl: `${host}/yy/pld_264_new.mp4`,
videoUrl: videoUrl || `${host}/yy/pld_264_new.mp4`,
effects: {
1: '/yy/b6.png',
2: '/yy/b6c.png',
Expand Down
3 changes: 2 additions & 1 deletion projects/offical/src/preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import Layout from './Layout'
// import 'antd/dist/antd.min.css'
import './common.css'
import Jcx from './view/Jcx'
import {videoUrl} from './config/video'

const Privew = () => (
<>
<Layout />
<Jcx />
{!videoUrl && <Jcx />}
</>
)
export default Privew

0 comments on commit 9b63d98

Please sign in to comment.