Home > other >  About cocos2d background music on IOS devices cannot be played normally
About cocos2d background music on IOS devices cannot be played normally

Time:09-24

the younger brother to locate where the problem is not now, what a big help to have a look at:
Recent work on a project, the cocos2d h5 game to join in the project, WKWebView are using a third-party dsbridge framework (https://github.com/wendux/DSBridge-IOS), at the time of development, found that voice cannot play game,
1, in the later time, to make a study of the problem using safari debug, when joining a breakpoint, click on the pause in the beginning, music playback, normal again, click again there was no voice,

After 2, play games and the development of communication, game developers put the data on the local, to join the game, music is a normal play, we put the game on the server, and call out the problem in game, cannot play music,

3, here are my initial Web dsbridge code, what a big help me see initializing the Web configuration have what problem:
 - (DWKWebView *) webView {

if (! _webView) {
Init WKUserContentController * _userContentController=[[WKUserContentController alloc]].
Init WKWebViewConfiguration * config=[[WKWebViewConfiguration alloc]].
The config. MediaTypesRequiringUserActionForPlayback=WKAudiovisualMediaTypeNone;
The config. AllowsInlineMediaPlayback=YES;
[config setValue: @ YES forKey: @ "_allowUniversalAccessFromFileURLs"].
[config. UserContentController addScriptMessageHandler: self name: kCustomJSLoggerName];
WKUserScript * cookieScript=[[WKUserScript alloc] initWithSource: @ "document. The cookie='skey=skeyValue;" injectionTime: WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly: NO];
[_userContentController addUserScript: cookieScript];

_webView=[[DWKWebView alloc] initWithFrame: CGRectZero configuration: config];
_webView. AutoresizingMask=UIViewAutoresizingFlexibleWidth;
[_webView addJavascriptObject: self namespace: nil];
_webView. DSUIDelegate=self;
[_webView setDebugMode: YES];
_webView. NavigationDelegate=self;
}
Return _webView;
}








  • Related