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

App在后台呆了一会,回到前台后,动画停止播放了。 #2109

Open
petyou opened this issue Jan 23, 2024 · 5 comments
Open

App在后台呆了一会,回到前台后,动画停止播放了。 #2109

petyou opened this issue Jan 23, 2024 · 5 comments
Assignees

Comments

@petyou
Copy link

petyou commented Jan 23, 2024

【版本信息】

4.3.47

【平台信息】

iOS 原生

【预期的表现】

播放中的动画,在app退到后台后超过10s中,再回到前台时,动画继续播放。

【实际的情况】

播放中的动画,在app退到后台后超过10s中,再回到前台时,动画停止了,且无法调用play方法继续播放

20240123-225928.mp4

【Demo及附件】

官方demo即可复现

@kevingpqi123
Copy link
Collaborator

你确认下是否调用了 setRepeatCount 接口,如果没有调用,默认是只播放一次,进入后台后,定时器并没有停止,只是停止了渲染,如果播放次数没有设置或者设置次数较少是会出现你所说的情况,这是正常的
要解决这个问题,增加调用 setRepeatCount(0)即可

@petyou
Copy link
Author

petyou commented Jan 24, 2024

@kevingpqi123 上述录屏来自于官方提供的最新demo(未作任何修改),看了demo中的代码已经设置了 setRepeatCount(0)。
`- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
if ([self.pagView isPlaying]) {
[self.pagView stop];
} else {
[self.pagView play];
}

}

/**
初始化PAGView
*/

  • (void)initPAGView {
    //读取PAG素材文件
    NSString* resourcePath = [self resourcePath];
    self.pagFile = [PAGFile Load:resourcePath];

    //创建PAG播放视图PAGView
    self.pagView = [[PAGView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:self.pagView];

    //关联PAGView和PAGFile
    [self.pagView setComposition:self.pagFile];
    //3.0中pagView中可以使用setPath直接使用file,setPath在pag中会根据path缓存pagFile,实现一次加载多个地方调用
    //[self.pagView setPath:resourcePath];
    //3.0中 [self.pagView setFile:self.pagFile]方法被废弃,如果使用setFile则无法通过file对替换数据进行控制;

    //设置循环播放,默认只播放一次
    [self.pagView setRepeatCount:0];

    //播放
    [self.pagView play];

    [self.view sendSubviewToBack:self.pagView];
    }

`

下载地址:https://pag.art/docs/pad-demo-download.html

@Creolophus
Copy link

一样碰到从后台回前台偶发暂停播放

@petyou
Copy link
Author

petyou commented Feb 19, 2024

@kevingpqi123 大佬解决下啊,这个描述得够清楚了,官方给的demo都能复现。按道理说是个严重问题啊。。

@DongDian455
Copy link

ios退到后台30秒,回到前台无法播放

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

4 participants