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

fix browser breaking when playing audio on uc browser #5048

Merged
merged 2 commits into from Aug 2, 2019
Merged

fix browser breaking when playing audio on uc browser #5048

merged 2 commits into from Aug 2, 2019

Conversation

@Marssssssss
Copy link

@Marssssssss Marssssssss commented Aug 1, 2019

Re: cocos-creator/2d-tasks#1636

Changes:

  • now when using uc browser to play audio, the delay time before setting takes effects will be set to 0.01s.
PPpro
PPpro approved these changes Aug 1, 2019
@Marssssssss
Copy link
Author

@Marssssssss Marssssssss commented Aug 1, 2019

UC浏览器的开发者平台对 navigator.userAgent 的输出

image

@@ -1022,6 +1022,8 @@ function initSys () {
browserType = sys.BROWSER_TYPE_MAXTHON;
else if (browserType === "opr/")
browserType = sys.BROWSER_TYPE_OPERA;
else if (browserType === "ucbrowser" || browserType === 'ubrowser')
Copy link
Member

@jareguo jareguo Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

@PPpro PPpro Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那么多 if-else 判断,可以改成查表的方式

Copy link
Contributor

@PPpro PPpro Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let typeMap = {
    'edge': sys.BROWSER_TYPE_EDGE,
    "360 aphone": sys.BROWSER_TYPE_360,
    ....
}
sys.browserType = typeMap[browserType] || browserType;

@@ -995,7 +995,7 @@ function initSys () {
/* Determine the browser type */
(function(){
var typeReg1 = /mqqbrowser|micromessenger|qq|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i;
var typeReg2 = /qqbrowser|ucbrowser|edge/i;
var typeReg2 = /qqbrowser|ucbrowser|edge|ubrowser/i;
var typeReg3 = /chrome|safari|firefox|trident|opera|opr\/|oupeng/i;
var browserTypes = typeReg1.exec(ua);
if(!browserTypes) browserTypes = typeReg2.exec(ua);
Copy link
Contributor

@PPpro PPpro Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var browserTypes = typeReg1.exec(ua) || typeReg2.exec(ua) || typeReg3.exec(ua)

@@ -995,7 +995,7 @@ function initSys () {
/* Determine the browser type */
(function(){
var typeReg1 = /mqqbrowser|micromessenger|qq|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i;
var typeReg2 = /qqbrowser|ucbrowser|edge/i;
var typeReg2 = /qqbrowser|ucbrowser|edge|ubrowser/i;
Copy link
Contributor

@PPpro PPpro Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var typeReg2 = /qqbrowser|ucbrowser|ubrowser|edge/i;

@@ -1022,6 +1022,8 @@ function initSys () {
browserType = sys.BROWSER_TYPE_MAXTHON;
else if (browserType === "opr/")
browserType = sys.BROWSER_TYPE_OPERA;
else if (browserType === "ucbrowser" || browserType === 'ubrowser')
Copy link
Contributor

@PPpro PPpro Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那么多 if-else 判断,可以改成查表的方式

PPpro
PPpro approved these changes Aug 2, 2019
@jareguo jareguo merged commit a3de003 into cocos-creator:v2.1.3 Aug 2, 2019
1 check passed
@Marssssssss Marssssssss deleted the 2.1.3_audio branch Aug 2, 2019
jareguo added a commit that referenced this issue Aug 2, 2019
* commit 'a3de003db47b4afa537a97b829ad75069f48be95':
  fix browser breaking when playing audio on uc browser (#5048)
  fix vec2、vec3、vec4 parameters type error (#5064)
  Fix call node targetOff func has not remove node from target.__eventTargets array (#5052)
  add play and stop sub particle for editor mode (#5031)
  fix IE11's not supporting to Array.includes (#5033)
  fix issue #4942
  BUG FIX: audio fail to register touch event listener && fix audio loading (#4991)
  fix ecScene null (#5000)
  Lifecycle: always call start, update, lateUpdate in try catch (#4941)
  Fix a memory leak caused by the render-data not being properly released! (#5025)
  avoid releasing builtin asset (#4915)
  fix auto sync prefab rotation and z invalid (#4975)
  revert fix pageview inertia invalid (#4945) (#4968)
  refine code (#4964)
  fix pageview inertia invalid (#4945)

# Conflicts:
#	cocos2d/audio/CCAudio.js
#	cocos2d/core/graphics/graphics.js
#	cocos2d/core/load-pipeline/audio-downloader.js
#	cocos2d/core/platform/CCSys.js
#	cocos2d/core/renderer/index.js
#	cocos2d/core/utils/prefab-helper.js
#	cocos2d/renderer/render-data/render-data.js
#	cocos2d/tilemap/CCTiledMap.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants