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
vap 无法替换播放资源。 #63
Comments
麻烦贴下出问题的日志 |
情况一 先调用stopplay再调用play 表现为白屏:
代码 class MainActivity : AppCompatActivity() {
private lateinit var animView: AnimView
private lateinit var btnSwitch: AppCompatButton
private var count = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initView()
}
private fun initView() {
animView = findViewById(R.id.animView)
btnSwitch = findViewById(R.id.btnSwitch)
animView.showAni("demo.mp4", true)
btnSwitch.setOnClickListener {
animView.stopPlay()
when (count) {
0 -> {
animView.showAni("vapx.mp4", true)
count = 1
}
1 -> {
animView.showAni("demo.mp4", true)
count = 0
}
}
}
}
}
fun AnimView.showAni(name: String, loop: Boolean = false) {
if (loop) {
setLoop(Int.MAX_VALUE)
}
startPlay(context.assets, name)
} |
情况二 不调用stopplay直接调用play播放另一个 表现为界面没任何切换:
代码 class MainActivity : AppCompatActivity() {
private lateinit var animView: AnimView
private lateinit var btnSwitch: AppCompatButton
private var count = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initView()
}
private fun initView() {
animView = findViewById(R.id.animView)
btnSwitch = findViewById(R.id.btnSwitch)
animView.showAni("demo.mp4", true)
btnSwitch.setOnClickListener {
//animView.stopPlay()
when (count) {
0 -> {
animView.showAni("vapx.mp4", true)
count = 1
}
1 -> {
animView.showAni("demo.mp4", true)
count = 0
}
}
}
}
}
fun AnimView.showAni(name: String, loop: Boolean = false) {
if (loop) {
setLoop(Int.MAX_VALUE)
}
startPlay(context.assets, name)
} |
你没有注册日志接口吧,vap的日志都没打印出来 |
这个接口有兼容问题 |
先stop后play 不stop直接play |
我试过用file的,表现一致,就使用asset的方法了。暂时没发现其他问题。 |
可以给我带tag带AnimPlayer,的所有日志,发出来看看 |
不stop直接play
|
先stop后play
|
我先看看 |
好的,麻烦大佬了。另外你说的那个兼容性问题我可能遇到了。 |
看你代码你是在同时先调用stop马上调用start,这样是不行的,因为stop是异步操作,start不能直接着stop调用,要等待onComplete回调才能调用start |
我等下试试看 |
测试过了,在oncomplete中播放下一个 确实没问题 |
问题解决了是吧,我先关闭问题了 |
如果调用了stopPlay,则需要在onVideoDestroy中播放下一个才正常,不然解析文件时会遇到文件流被close而抛出异常 |
问题描述:
使用animview起播某个动画资源,stopplay后再播放另一个动画没效果,什么都不显示。如果不stopplay就播放另一个,会提示is running can not start
The text was updated successfully, but these errors were encountered: