Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

视频拉伸 #164

Closed
zijinzhiyun opened this issue Nov 5, 2021 · 7 comments
Closed

视频拉伸 #164

zijinzhiyun opened this issue Nov 5, 2021 · 7 comments

Comments

@zijinzhiyun
Copy link

您好,demo中animView.startPlay(file)不在新开的线程中执行,直接在主线程中执行会出现拉伸。
README.md中没有说明animView.startPlay(file)要在子线程中进行,如果需要在子线程中运行,是否可以把在子线程中运行的逻辑封装在animView.startPlay方法中

@hexleo
Copy link
Collaborator

hexleo commented Nov 8, 2021

拉伸与否与是否在哪个线程无关,你可以看看这个接口是设置拉伸参数的 setScaleType(type: ScaleType)

@hexleo hexleo closed this as completed Nov 8, 2021
@zijinzhiyun
Copy link
Author

zijinzhiyun commented Nov 8, 2021

@hexleo 原因是在onCreate中直接调用animView.startPlay()方法,如果这时AnimView.onSizeChanged()没有调用,prepareTextureView()中scaleTypeUtil.getLayoutParam获取到的宽高都为0,就会出现setScaleType设置无效的情况,视频就有可能会被拉伸。这种情况不是必现,多次尝试就会出现。

@hexleo
Copy link
Collaborator

hexleo commented Nov 9, 2021

我看看这个问题,你可以先用一个handler post这个startPlay,延后执行解决这个问题

@hexleo hexleo reopened this Nov 9, 2021
@hexleo
Copy link
Collaborator

hexleo commented Nov 9, 2021

我看这块代码,应该已经post到主线程了,按理说onCreate应该已经执行完成,你再检查下是不是在play之前,你的AnimView设置的宽高就是0呀,到调用播放后才开始设置宽高?或者之前是gone,播放后才设置为visable?
image

@zijinzhiyun
Copy link
Author

zijinzhiyun commented Nov 9, 2021

AnimView xml中layout_width和layout_height设置的都是match_parent,在onCreate中直接setScaleType,然后startPlay本地一个已有的VAP文件,就有可能复现这个问题,在启动Activity中更容易复现。
我打印日志,发现出现这种情况是innerStartPlay() -> prepareTextureView() -> prepareTextureView uiHandler.post() -> 打印params error: layoutWidth=0, layoutHeight=0, videoWidth=750, videoHeight=1334 -> onAttachedToWindow() -> onSizeChanged()

@hexleo
Copy link
Collaborator

hexleo commented Nov 9, 2021

你切换到这个分支bugfix/android_scaletype,修复你说的这个问题,你先试试,如果没问题我就合入主干

@zijinzhiyun
Copy link
Author

视频正常了,没有问题了,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants