[add] iOS Android特別處理
This commit is contained in:
parent
6cb232192e
commit
62093148f3
@ -35,7 +35,9 @@ export default class Manager extends cc.Component {
|
|||||||
let data: any = e.data;
|
let data: any = e.data;
|
||||||
let method: string = data.method;
|
let method: string = data.method;
|
||||||
let value: any = data.value;
|
let value: any = data.value;
|
||||||
|
if (method) {
|
||||||
self.Birdge(method, ...value);
|
self.Birdge(method, ...value);
|
||||||
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
if (!window["Bridge"]) {
|
if (!window["Bridge"]) {
|
||||||
@ -43,14 +45,23 @@ export default class Manager extends cc.Component {
|
|||||||
self.Birdge(method, value);
|
self.Birdge(method, value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
let scheme: string = "jmka";
|
||||||
|
this.webview.setJavascriptInterfaceScheme(scheme);
|
||||||
|
this.webview.setOnJSCallback((sender, url) => {
|
||||||
|
let data: JSON = JSON.parse(decodeURI(url.split(`${scheme}://`)[1]));
|
||||||
|
let method: any = data["method"];
|
||||||
|
let value: any = data["value"];
|
||||||
|
if (method) {
|
||||||
|
self.Birdge(method, ...value);
|
||||||
|
}
|
||||||
|
});
|
||||||
let href: string = window.location.href;
|
let href: string = window.location.href;
|
||||||
|
|
||||||
|
let url: string = `http://220.134.195.1/public/bonus_casino/html5/jianmiau/Test/?host=${href}&v=${Date.now()}`;
|
||||||
// let url: string = `https://karolchang.github.io/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`;
|
// let url: string = `https://karolchang.github.io/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`;
|
||||||
// let url: string = `http://220.134.195.1/public/bonus_casino/html5/jianmiau/BJ_Casino_Rank/?v=${Date.now()}`;
|
|
||||||
// let url: string = `http://karol.jianmiau.cf/jm-expense-vue-ts/?v=${Date.now()}`;
|
// let url: string = `http://karol.jianmiau.cf/jm-expense-vue-ts/?v=${Date.now()}`;
|
||||||
let url: string = `https://jm-expense-2022.firebaseapp.com/login?v=${Date.now()}`;
|
// let url: string = `https://jm-expense-2022.firebaseapp.com/login?host=${href}&v=${Date.now()}`;
|
||||||
this.webview.url = url;
|
this.webview.url = url;
|
||||||
// this.webview.url = `http://localhost:8080/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`;
|
|
||||||
this.webview.node.active = true;
|
this.webview.node.active = true;
|
||||||
|
|
||||||
cc.view.setResizeCallback(this._resize.bind(this));
|
cc.view.setResizeCallback(this._resize.bind(this));
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// import Text_to_Speech from "./Text_to_Speech";
|
||||||
|
|
||||||
const { ccclass } = cc._decorator;
|
const { ccclass } = cc._decorator;
|
||||||
|
|
||||||
@ccclass
|
@ccclass
|
||||||
@ -17,6 +19,12 @@ export default class NativeClass extends cc.Component {
|
|||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region private
|
||||||
|
|
||||||
|
// private _text_to_Speech: Text_to_Speech;
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region Lifecycle
|
//#region Lifecycle
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -27,6 +35,7 @@ export default class NativeClass extends cc.Component {
|
|||||||
|
|
||||||
private init(): void {
|
private init(): void {
|
||||||
let self: this = this;
|
let self: this = this;
|
||||||
|
// this._text_to_Speech = new Text_to_Speech();
|
||||||
let HttpData: any[] = [];
|
let HttpData: any[] = [];
|
||||||
// let HttpParmData: any[] = [];
|
// let HttpParmData: any[] = [];
|
||||||
// 註冊要被Java、OC呼叫的事件
|
// 註冊要被Java、OC呼叫的事件
|
||||||
@ -135,6 +144,7 @@ export default class NativeClass extends cc.Component {
|
|||||||
}
|
}
|
||||||
case cc.sys.OS_ANDROID: {
|
case cc.sys.OS_ANDROID: {
|
||||||
jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "TTS_Play", "(Ljava/lang/String;)V", msg);
|
jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "TTS_Play", "(Ljava/lang/String;)V", msg);
|
||||||
|
// this._text_to_Speech.speak(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ver": "1.0.8",
|
"ver": "1.1.0",
|
||||||
"uuid": "5558f747-ed9e-4040-9a01-3b89b99ac37a",
|
"uuid": "5558f747-ed9e-4040-9a01-3b89b99ac37a",
|
||||||
|
"importer": "typescript",
|
||||||
"isPlugin": false,
|
"isPlugin": false,
|
||||||
"loadPluginInWeb": true,
|
"loadPluginInWeb": true,
|
||||||
"loadPluginInNative": true,
|
"loadPluginInNative": true,
|
||||||
|
41
assets/Script/Text_to_Speech.ts
Normal file
41
assets/Script/Text_to_Speech.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
const responsiveVoice = window["responsiveVoice"];
|
||||||
|
|
||||||
|
export default class Text_to_Speech {
|
||||||
|
//#region 外調參數
|
||||||
|
|
||||||
|
private voice: string = null;
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region Custom
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
let self: this = this;
|
||||||
|
responsiveVoice.init();
|
||||||
|
var voicelist = responsiveVoice.getVoices();
|
||||||
|
this.setDefaultVoice(voicelist[14].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setDefaultVoice(voice: string): void {
|
||||||
|
this.voice = voice;
|
||||||
|
responsiveVoice.setDefaultVoice(voice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public speak(msg: string): void {
|
||||||
|
let self: this = this;
|
||||||
|
if (responsiveVoice.voiceSupport()) {
|
||||||
|
responsiveVoice.speak(msg, this.voice, {
|
||||||
|
onstart: function (Callback: any): void {
|
||||||
|
console.log(`onstart msg: ${msg}`);
|
||||||
|
},
|
||||||
|
onend: function (Callback: any): void {
|
||||||
|
console.log(`onstart msg: ${msg}`);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error(`!responsiveVoice.voiceSupport`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
}
|
10
assets/Script/Text_to_Speech.ts.meta
Normal file
10
assets/Script/Text_to_Speech.ts.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.0",
|
||||||
|
"uuid": "59151148-7427-4d5f-a981-41c6adb57700",
|
||||||
|
"importer": "typescript",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user