mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
[adjsut] rename jsb to ral (#8327)
* [adjsut] rename jsb to ral ,add ovh jsb.js * [adjust] adjust * [adjust] adjust adapter * [adjust] update adapter * [adjust] updata adapter * [bug] fix cannot run in cocos play * [bug] fix vivo cannot run * [adjust]rename jsb.js to ral.js
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
const inputManager = cc.internal.inputManager;
|
||||
const jsb = window.jsb;
|
||||
const ral = window.ral;
|
||||
|
||||
function accelerometerChangeCb (res) {
|
||||
function accelerometerChangeCb(res) {
|
||||
let x = res.x;
|
||||
let y = res.y;
|
||||
if (jsb._isLandscape) {
|
||||
if (ral._isLandscape) {
|
||||
let tmp = x;
|
||||
x = -y;
|
||||
y = tmp;
|
||||
}
|
||||
|
||||
|
||||
if (inputManager._acceleration) {
|
||||
// NOTE: jsb.onDeviceOrientationChange not supported
|
||||
// inputManager._acceleration.x = x * deviceOrientation;
|
||||
@@ -21,7 +21,7 @@ function accelerometerChangeCb (res) {
|
||||
}
|
||||
|
||||
Object.assign(inputManager, {
|
||||
setAccelerometerEnabled (isEnable) {
|
||||
setAccelerometerEnabled(isEnable) {
|
||||
let scheduler = cc.director.getScheduler();
|
||||
cc.Scheduler.enableForTarget(this);
|
||||
if (isEnable) {
|
||||
@@ -34,20 +34,20 @@ Object.assign(inputManager, {
|
||||
}
|
||||
},
|
||||
|
||||
setAccelerometerInterval (interval) {
|
||||
setAccelerometerInterval(interval) {
|
||||
// TODO
|
||||
},
|
||||
|
||||
_registerAccelerometerEvent () {
|
||||
_registerAccelerometerEvent() {
|
||||
this._accelCurTime = 0;
|
||||
this._acceleration = new cc.internal.Acceleration();
|
||||
jsb.onAccelerometerChange(accelerometerChangeCb);
|
||||
jsb.startAccelerometer();
|
||||
ral.onAccelerometerChange(accelerometerChangeCb);
|
||||
ral.startAccelerometer();
|
||||
},
|
||||
|
||||
_unregisterAccelerometerEvent () {
|
||||
_unregisterAccelerometerEvent() {
|
||||
this._accelCurTime = 0;
|
||||
jsb.stopAccelerometer();
|
||||
jsb.offAccelerometerChange(accelerometerChangeCb);
|
||||
ral.stopAccelerometer();
|
||||
ral.offAccelerometerChange(accelerometerChangeCb);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
let _hideKeyboardTimeout = null;
|
||||
let _currentEditBoxImpl = null;
|
||||
|
||||
function getKeyboardReturnType (type) {
|
||||
function getKeyboardReturnType(type) {
|
||||
switch (type) {
|
||||
case KeyboardReturnType.DEFAULT:
|
||||
case KeyboardReturnType.DONE:
|
||||
@@ -28,7 +28,7 @@
|
||||
return 'done';
|
||||
}
|
||||
|
||||
function MiniGameEditBoxImpl () {
|
||||
function MiniGameEditBoxImpl() {
|
||||
this._delegate = null;
|
||||
this._editing = false;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
EditBoxComp._EditBoxImpl = MiniGameEditBoxImpl;
|
||||
|
||||
Object.assign(MiniGameEditBoxImpl.prototype, {
|
||||
init (delegate) {
|
||||
init(delegate) {
|
||||
if (!delegate) {
|
||||
cc.error('EditBox init failed');
|
||||
return;
|
||||
@@ -51,7 +51,7 @@
|
||||
this._delegate = delegate;
|
||||
},
|
||||
|
||||
beginEditing () {
|
||||
beginEditing() {
|
||||
// In case multiply register events
|
||||
if (this._editing) {
|
||||
return;
|
||||
@@ -66,13 +66,13 @@
|
||||
});
|
||||
},
|
||||
|
||||
endEditing () {
|
||||
endEditing() {
|
||||
this._hideKeyboard();
|
||||
let cbs = this._eventListeners;
|
||||
cbs.onKeyboardComplete && cbs.onKeyboardComplete();
|
||||
},
|
||||
|
||||
_registerKeyboardEvent () {
|
||||
_registerKeyboardEvent() {
|
||||
let self = this;
|
||||
let delegate = this._delegate;
|
||||
let cbs = this._eventListeners;
|
||||
@@ -96,33 +96,33 @@
|
||||
delegate._editBoxEditingDidEnded();
|
||||
}
|
||||
|
||||
jsb.onKeyboardInput(cbs.onKeyboardInput);
|
||||
jsb.onKeyboardConfirm(cbs.onKeyboardConfirm);
|
||||
jsb.onKeyboardComplete(cbs.onKeyboardComplete);
|
||||
ral.onKeyboardInput(cbs.onKeyboardInput);
|
||||
ral.onKeyboardConfirm(cbs.onKeyboardConfirm);
|
||||
ral.onKeyboardComplete(cbs.onKeyboardComplete);
|
||||
},
|
||||
|
||||
_unregisterKeyboardEvent () {
|
||||
_unregisterKeyboardEvent() {
|
||||
let cbs = this._eventListeners;
|
||||
|
||||
if (cbs.onKeyboardInput) {
|
||||
jsb.offKeyboardInput(cbs.onKeyboardInput);
|
||||
ral.offKeyboardInput(cbs.onKeyboardInput);
|
||||
cbs.onKeyboardInput = null;
|
||||
}
|
||||
if (cbs.onKeyboardConfirm) {
|
||||
jsb.offKeyboardConfirm(cbs.onKeyboardConfirm);
|
||||
ral.offKeyboardConfirm(cbs.onKeyboardConfirm);
|
||||
cbs.onKeyboardConfirm = null;
|
||||
}
|
||||
if (cbs.onKeyboardComplete) {
|
||||
jsb.offKeyboardComplete(cbs.onKeyboardComplete);
|
||||
ral.offKeyboardComplete(cbs.onKeyboardComplete);
|
||||
cbs.onKeyboardComplete = null;
|
||||
}
|
||||
},
|
||||
|
||||
_otherEditing () {
|
||||
_otherEditing() {
|
||||
return !!_currentEditBoxImpl && _currentEditBoxImpl !== this && _currentEditBoxImpl._editing;
|
||||
},
|
||||
|
||||
_ensureKeyboardHide (cb) {
|
||||
_ensureKeyboardHide(cb) {
|
||||
let otherEditing = this._otherEditing();
|
||||
if (!otherEditing && !_hideKeyboardTimeout) {
|
||||
return cb();
|
||||
@@ -139,30 +139,30 @@
|
||||
}, KEYBOARD_HIDE_TIME);
|
||||
},
|
||||
|
||||
_showKeyboard () {
|
||||
_showKeyboard() {
|
||||
let delegate = this._delegate;
|
||||
let multiline = (delegate.inputMode === EditBoxComp.InputMode.ANY);
|
||||
jsb.showKeyboard({
|
||||
ral.showKeyboard({
|
||||
defaultValue: delegate.string,
|
||||
maxLength: delegate.maxLength < 0 ? MAX_VALUE : delegate.maxLength,
|
||||
multiple: multiline,
|
||||
confirmHold: false,
|
||||
confirmType: getKeyboardReturnType(delegate.returnType),
|
||||
success (res) {
|
||||
success(res) {
|
||||
|
||||
},
|
||||
fail (res) {
|
||||
fail(res) {
|
||||
cc.warn(res.errMsg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_hideKeyboard () {
|
||||
jsb.hideKeyboard({
|
||||
success (res) {
|
||||
_hideKeyboard() {
|
||||
ral.hideKeyboard({
|
||||
success(res) {
|
||||
|
||||
},
|
||||
fail (res) {
|
||||
fail(res) {
|
||||
cc.warn(res.errMsg);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ const canvasPosition = {
|
||||
|
||||
Object.defineProperties(canvasPosition, {
|
||||
width: {
|
||||
get () {
|
||||
get() {
|
||||
return window.innerWidth;
|
||||
},
|
||||
},
|
||||
height: {
|
||||
get () {
|
||||
get() {
|
||||
return window.innerHeight;
|
||||
},
|
||||
},
|
||||
@@ -19,10 +19,10 @@ Object.defineProperties(canvasPosition, {
|
||||
|
||||
if (mgr) {
|
||||
Object.assign(mgr, {
|
||||
_updateCanvasBoundingRect () {},
|
||||
_updateCanvasBoundingRect() { },
|
||||
|
||||
registerSystemEvent (element) {
|
||||
if(this._isRegisterEvent) return;
|
||||
registerSystemEvent(element) {
|
||||
if (this._isRegisterEvent) return;
|
||||
|
||||
this._glView = cc.view;
|
||||
let self = this;
|
||||
@@ -37,7 +37,7 @@ if (mgr) {
|
||||
|
||||
let registerTouchEvent = function (eventName) {
|
||||
let handler = _touchEventsMap[eventName];
|
||||
jsb[eventName](function (event) {
|
||||
ral[eventName](function (event) {
|
||||
if (!event.changedTouches) return;
|
||||
handler.call(self, self.getTouchesByEvent(event, canvasPosition));
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cacheManager = require('./cache-manager');
|
||||
const { downloadFile, readText, readArrayBuffer, readJson, loadSubpackage, getUserDataPath, _subpackagesPath } = require('./fs-utils');
|
||||
cc.assetManager.fsUtils = jsb.fsUtils;
|
||||
cc.assetManager.fsUtils = ral.fsUtils;
|
||||
|
||||
const REGEX = /^https?:\/\/.*/;
|
||||
|
||||
@@ -99,7 +99,7 @@ function downloadText(url, options, onComplete) {
|
||||
download(url, parseText, options, options.onFileProgress, onComplete);
|
||||
}
|
||||
|
||||
function downloadJson (url, options, onComplete) {
|
||||
function downloadJson(url, options, onComplete) {
|
||||
download(url, parseJson, options, options.onFileProgress, onComplete);
|
||||
}
|
||||
|
||||
@@ -153,12 +153,12 @@ function downloadBundle(nameOrUrl, options, onComplete) {
|
||||
onComplete(err, null);
|
||||
return;
|
||||
}
|
||||
downloader.importBundleEntry(bundleName).then(function() {
|
||||
downloader.importBundleEntry(bundleName).then(function () {
|
||||
downloadJson(config, options, function (err, data) {
|
||||
data && (data.base = `${_subpackagesPath}${bundleName}/`);
|
||||
onComplete(err, data);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
}).catch(function (err) {
|
||||
onComplete(err);
|
||||
});
|
||||
});
|
||||
@@ -187,7 +187,7 @@ function downloadBundle(nameOrUrl, options, onComplete) {
|
||||
loadedScripts[js] = true;
|
||||
}
|
||||
|
||||
downloader.importBundleEntry(bundleName).then(function() {
|
||||
downloader.importBundleEntry(bundleName).then(function () {
|
||||
options.__cacheBundleRoot__ = bundleName;
|
||||
var config = `${url}/config.${suffix}json`;
|
||||
downloadJson(config, options, function (err, data) {
|
||||
@@ -212,7 +212,7 @@ function downloadBundle(nameOrUrl, options, onComplete) {
|
||||
onComplete && onComplete(null, data);
|
||||
}
|
||||
});
|
||||
}).catch(function(err) {
|
||||
}).catch(function (err) {
|
||||
onComplete && onComplete(err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
let originalCreateCanvas = jsb.createCanvas.bind(jsb);
|
||||
jsb.createCanvas = function () {
|
||||
let originalCreateCanvas = ral.createCanvas.bind(ral);
|
||||
ral.createCanvas = function () {
|
||||
let canvas = originalCreateCanvas();
|
||||
canvas.style = {}; // canvas has no style property on runtime 2.0
|
||||
return canvas;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
const downloader = cc.assetManager.downloader;
|
||||
const parser = cc.assetManager.parser;
|
||||
|
||||
function loadInnerAudioContext (url) {
|
||||
function loadInnerAudioContext(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const nativeAudio = jsb.createInnerAudioContext();
|
||||
|
||||
const nativeAudio = ral.createInnerAudioContext();
|
||||
|
||||
let timer = setTimeout(() => {
|
||||
clearEvent();
|
||||
resolve(nativeAudio);
|
||||
}, 8000);
|
||||
function clearEvent () {
|
||||
function clearEvent() {
|
||||
nativeAudio.offCanplay(success);
|
||||
nativeAudio.offError(fail);
|
||||
}
|
||||
function success () {
|
||||
function success() {
|
||||
clearEvent();
|
||||
clearTimeout(timer);
|
||||
resolve(nativeAudio);
|
||||
}
|
||||
function fail () {
|
||||
function fail() {
|
||||
clearEvent();
|
||||
clearTimeout(timer);
|
||||
reject('failed to load innerAudioContext: ' + err);
|
||||
@@ -28,7 +28,7 @@ function loadInnerAudioContext (url) {
|
||||
nativeAudio.src = url;
|
||||
});
|
||||
}
|
||||
function downloadAudio (url, options, onComplete) {
|
||||
function downloadAudio(url, options, onComplete) {
|
||||
loadInnerAudioContext(url).then(nativeAudio => {
|
||||
onComplete(null, nativeAudio);
|
||||
}, err => {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
var fs = jsb.getFileSystemManager ? jsb.getFileSystemManager() : null;
|
||||
var fs = ral.getFileSystemManager ? ral.getFileSystemManager() : null;
|
||||
var outOfStorageRegExp = /the maximum size of the file storage/;
|
||||
|
||||
var fsUtils = {
|
||||
@@ -31,15 +31,15 @@ var fsUtils = {
|
||||
|
||||
_subpackagesPath: 'usr_',
|
||||
|
||||
isOutOfStorage (errMsg) {
|
||||
isOutOfStorage(errMsg) {
|
||||
return outOfStorageRegExp.test(errMsg);
|
||||
},
|
||||
|
||||
getUserDataPath () {
|
||||
return jsb.env.USER_DATA_PATH;
|
||||
getUserDataPath() {
|
||||
return ral.env.USER_DATA_PATH;
|
||||
},
|
||||
|
||||
checkFsValid () {
|
||||
checkFsValid() {
|
||||
if (!fs) {
|
||||
console.warn('can not get the file system!');
|
||||
return false;
|
||||
@@ -47,7 +47,7 @@ var fsUtils = {
|
||||
return true;
|
||||
},
|
||||
|
||||
deleteFile (filePath, onComplete) {
|
||||
deleteFile(filePath, onComplete) {
|
||||
fs.unlink({
|
||||
filePath: filePath,
|
||||
success: function () {
|
||||
@@ -60,7 +60,7 @@ var fsUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
downloadFile (remoteUrl, filePath, header, onProgress, onComplete) {
|
||||
downloadFile(remoteUrl, filePath, header, onProgress, onComplete) {
|
||||
var options = {
|
||||
url: remoteUrl,
|
||||
success: function (res) {
|
||||
@@ -82,12 +82,12 @@ var fsUtils = {
|
||||
}
|
||||
if (filePath) options.filePath = filePath;
|
||||
if (header) options.header = header;
|
||||
var task = jsb.downloadFile(options);
|
||||
var task = ral.downloadFile(options);
|
||||
onProgress && task.onProgressUpdate(onProgress);
|
||||
},
|
||||
|
||||
saveFile (srcPath, destPath, onComplete) {
|
||||
jsb.saveFile({
|
||||
saveFile(srcPath, destPath, onComplete) {
|
||||
ral.saveFile({
|
||||
tempFilePath: srcPath,
|
||||
filePath: destPath,
|
||||
success: function (res) {
|
||||
@@ -100,7 +100,7 @@ var fsUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
copyFile (srcPath, destPath, onComplete) {
|
||||
copyFile(srcPath, destPath, onComplete) {
|
||||
fs.copyFile({
|
||||
srcPath: srcPath,
|
||||
destPath: destPath,
|
||||
@@ -114,7 +114,7 @@ var fsUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
writeFile (path, data, encoding, onComplete) {
|
||||
writeFile(path, data, encoding, onComplete) {
|
||||
fs.writeFile({
|
||||
filePath: path,
|
||||
encoding: encoding,
|
||||
@@ -129,7 +129,7 @@ var fsUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
writeFileSync (path, data, encoding) {
|
||||
writeFileSync(path, data, encoding) {
|
||||
try {
|
||||
fs.writeFileSync(path, data, encoding);
|
||||
return null;
|
||||
@@ -140,7 +140,7 @@ var fsUtils = {
|
||||
}
|
||||
},
|
||||
|
||||
readFile (filePath, encoding, onComplete) {
|
||||
readFile(filePath, encoding, onComplete) {
|
||||
fs.readFile({
|
||||
filePath: filePath,
|
||||
encoding: encoding,
|
||||
@@ -149,12 +149,12 @@ var fsUtils = {
|
||||
},
|
||||
fail: function (res) {
|
||||
console.warn(`Read file failed: path: ${filePath} message: ${res.errMsg}`);
|
||||
onComplete && onComplete (new Error(res.errMsg), null);
|
||||
onComplete && onComplete(new Error(res.errMsg), null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
readDir (filePath, onComplete) {
|
||||
readDir(filePath, onComplete) {
|
||||
fs.readdir({
|
||||
dirPath: filePath,
|
||||
success: function (res) {
|
||||
@@ -167,15 +167,15 @@ var fsUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
readText (filePath, onComplete) {
|
||||
readText(filePath, onComplete) {
|
||||
fsUtils.readFile(filePath, 'utf8', onComplete);
|
||||
},
|
||||
|
||||
readArrayBuffer (filePath, onComplete) {
|
||||
fsUtils.readFile(filePath, '', onComplete);
|
||||
readArrayBuffer(filePath, onComplete) {
|
||||
fsUtils.readFile(filePath, 'binary', onComplete);
|
||||
},
|
||||
|
||||
readJson (filePath, onComplete) {
|
||||
readJson(filePath, onComplete) {
|
||||
fsUtils.readFile(filePath, 'utf8', function (err, text) {
|
||||
var out = null;
|
||||
if (!err) {
|
||||
@@ -191,7 +191,7 @@ var fsUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
readJsonSync (path) {
|
||||
readJsonSync(path) {
|
||||
try {
|
||||
var str = fs.readFileSync(path, 'utf8');
|
||||
return JSON.parse(str);
|
||||
@@ -202,7 +202,7 @@ var fsUtils = {
|
||||
}
|
||||
},
|
||||
|
||||
makeDirSync (path, recursive) {
|
||||
makeDirSync(path, recursive) {
|
||||
try {
|
||||
fs.mkdirSync(path, recursive);
|
||||
return null;
|
||||
@@ -213,7 +213,7 @@ var fsUtils = {
|
||||
}
|
||||
},
|
||||
|
||||
rmdirSync (dirPath, recursive) {
|
||||
rmdirSync(dirPath, recursive) {
|
||||
try {
|
||||
fs.rmdirSync(dirPath, recursive);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ var fsUtils = {
|
||||
}
|
||||
},
|
||||
|
||||
exists (filePath, onComplete) {
|
||||
exists(filePath, onComplete) {
|
||||
fs.access({
|
||||
path: filePath,
|
||||
success: function () {
|
||||
@@ -235,8 +235,8 @@ var fsUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
loadSubpackage (name, onProgress, onComplete) {
|
||||
var task = jsb.loadSubpackage({
|
||||
loadSubpackage(name, onProgress, onComplete) {
|
||||
var task = ral.loadSubpackage({
|
||||
name: `${fsUtils._subpackagesPath}${name}`,
|
||||
success: function () {
|
||||
onComplete && onComplete();
|
||||
@@ -250,14 +250,14 @@ var fsUtils = {
|
||||
return task;
|
||||
},
|
||||
|
||||
unzip (zipFilePath, targetPath, onComplete) {
|
||||
unzip(zipFilePath, targetPath, onComplete) {
|
||||
fs.unzip({
|
||||
zipFilePath,
|
||||
targetPath,
|
||||
success () {
|
||||
success() {
|
||||
onComplete && onComplete(null);
|
||||
},
|
||||
fail (res) {
|
||||
fail(res) {
|
||||
console.warn(`unzip failed: path: ${zipFilePath} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error('unzip failed: ' + res.errMsg));
|
||||
},
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
cc.game.restart = function () {
|
||||
};
|
||||
|
||||
jsb.onHide(function (data) {
|
||||
ral.onHide(function (data) {
|
||||
cc.game.emit(cc.Game.EVENT_HIDE);
|
||||
});
|
||||
|
||||
jsb.onShow(function () {
|
||||
ral.onShow(function () {
|
||||
cc.game.emit(cc.Game.EVENT_SHOW);
|
||||
});
|
||||
|
||||
jsb.onWindowResize && jsb.onWindowResize(function (width, height) {
|
||||
ral.onWindowResize && ral.onWindowResize(function (width, height) {
|
||||
// Since the initialization of the creator engine may not take place until after the onWindowResize call,
|
||||
// you need to determine whether the canvas already exists before you can call the setCanvasSize method
|
||||
cc.game.canvas && cc.view.setCanvasSize(width, height);
|
||||
|
||||
@@ -32,3 +32,7 @@ require('./game.js');
|
||||
require('./InputManager');
|
||||
require('./download-audio');
|
||||
require('./AudioPlayer');
|
||||
|
||||
if (jsb && !jsb.setPreferredFramesPerSecond) {
|
||||
jsb.setPreferredFramesPerSecond = ral.setPreferredFramesPerSecond.bind(ral);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
Object.assign(cc.sys, {
|
||||
__init () {
|
||||
__init() {
|
||||
this.isNative = false;
|
||||
this.isBrowser = false;
|
||||
this.isMobile = true;
|
||||
|
||||
let sysInfo = jsb.getSystemInfoSync();
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
// TODO: remove __getCurrentLanguage call
|
||||
let language = sysInfo.language || (__getCurrentLanguage && __getCurrentLanguage());
|
||||
this.language = language.substr(0, 2);
|
||||
@@ -65,13 +65,13 @@ Object.assign(cc.sys, {
|
||||
format: ['.mp3']
|
||||
};
|
||||
},
|
||||
|
||||
openURL (url) {
|
||||
jsb.openURL(url);
|
||||
|
||||
openURL(url) {
|
||||
console.warn("unspport openURL");
|
||||
},
|
||||
|
||||
getBatteryLevel () {
|
||||
const batteryInfo = jsb.getBatteryInfoSync();
|
||||
getBatteryLevel() {
|
||||
const batteryInfo = ral.getBatteryInfoSync();
|
||||
return batteryInfo && batteryInfo.level;
|
||||
},
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
let fs = jsb.getFileSystemManager();
|
||||
let fs = ral.getFileSystemManager();
|
||||
let gameConfig = JSON.parse(fs.readFileSync('./game.config.json', 'utf8'));
|
||||
jsb._isLandscape = gameConfig.deviceOrientation === 'landscape';
|
||||
ral._isLandscape = gameConfig.deviceOrientation === 'landscape';
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
let fs = jsb.getFileSystemManager();
|
||||
let fs = ral.getFileSystemManager();
|
||||
let gameConfig = JSON.parse(fs.readFileSync('./game.config.json', 'utf8'));
|
||||
jsb._isLandscape = gameConfig.deviceOrientation === 'landscape';
|
||||
ral._isLandscape = gameConfig.deviceOrientation === 'landscape';
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
let sysInfo = jsb.getSystemInfoSync();
|
||||
jsb._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
ral._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
let sysInfo = jsb.getSystemInfoSync();
|
||||
jsb._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
ral._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
@@ -1,9 +1,9 @@
|
||||
let originalResize = window.resize;
|
||||
let sysInfo = jsb.getSystemInfoSync();
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
let pixelRatio = sysInfo.pixelRatio;
|
||||
|
||||
// HACK: window.resize called by platform
|
||||
window.resize = function (width, height) {
|
||||
window.resize = function (width, height) {
|
||||
width /= pixelRatio;
|
||||
height /= pixelRatio;
|
||||
originalResize.call(window, width, height);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -33,7 +33,7 @@ if (cc.internal.VideoPlayer) {
|
||||
let _topLeft = new vec3();
|
||||
let _bottomRight = new vec3();
|
||||
|
||||
cc.internal.VideoPlayerImplManager.getImpl = function(componenet) {
|
||||
cc.internal.VideoPlayerImplManager.getImpl = function (componenet) {
|
||||
return new VideoPlayerImplMiniGame(componenet);
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ if (cc.internal.VideoPlayer) {
|
||||
this.createVideoPlayer(url);
|
||||
}
|
||||
|
||||
onCanplay () {
|
||||
onCanplay() {
|
||||
if (this._loaded) {
|
||||
return;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ if (cc.internal.VideoPlayer) {
|
||||
|
||||
}
|
||||
|
||||
_unbindEvent () {
|
||||
_unbindEvent() {
|
||||
let video = this._video;
|
||||
if (!video) {
|
||||
return;
|
||||
@@ -116,14 +116,14 @@ if (cc.internal.VideoPlayer) {
|
||||
}
|
||||
|
||||
createVideoPlayer(url) {
|
||||
if (!jsb.createVideo) {
|
||||
if (!ral.createVideo) {
|
||||
console.warn('VideoPlayer not supported');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._video) {
|
||||
let initRect = this._getInitRect();
|
||||
this._video = jsb.createVideo({
|
||||
this._video = ral.createVideo({
|
||||
...initRect, // OPPO video only can resize when it is initiated
|
||||
src: url,
|
||||
objectFit: "contain",
|
||||
@@ -144,7 +144,7 @@ if (cc.internal.VideoPlayer) {
|
||||
this._forceUpdate = true;
|
||||
}
|
||||
|
||||
setURL (path) {
|
||||
setURL(path) {
|
||||
let video = this._video;
|
||||
if (!video || video.src === path) {
|
||||
return;
|
||||
@@ -155,7 +155,7 @@ if (cc.internal.VideoPlayer) {
|
||||
video.muted = true;
|
||||
let self = this;
|
||||
this._loaded = false;
|
||||
|
||||
|
||||
var loadedCallback = function () {
|
||||
video.offPlay(loadedCallback);
|
||||
video.offTimeUpdate(timeCallBack);
|
||||
@@ -168,7 +168,7 @@ if (cc.internal.VideoPlayer) {
|
||||
self._currentTime = 0;
|
||||
self.dispatchEvent(EventType.READY_TO_PLAY);
|
||||
}
|
||||
|
||||
|
||||
var timeCallBack = function (res) {
|
||||
var data = JSON.parse(res.position);
|
||||
if (typeof data === "object") {
|
||||
@@ -181,7 +181,7 @@ if (cc.internal.VideoPlayer) {
|
||||
}
|
||||
video.onPlay(loadedCallback);
|
||||
video.onTimeUpdate(timeCallBack);
|
||||
|
||||
|
||||
// HACK: keep playing till video loaded
|
||||
video.play();
|
||||
}
|
||||
@@ -200,7 +200,7 @@ if (cc.internal.VideoPlayer) {
|
||||
}
|
||||
}
|
||||
|
||||
setVisible (value) {
|
||||
setVisible(value) {
|
||||
let video = this._video;
|
||||
if (!video || this._visible === value) {
|
||||
return;
|
||||
@@ -214,18 +214,18 @@ if (cc.internal.VideoPlayer) {
|
||||
this._visible = value;
|
||||
}
|
||||
|
||||
getDuration () {
|
||||
getDuration() {
|
||||
return this.duration();
|
||||
}
|
||||
|
||||
duration () {
|
||||
duration() {
|
||||
return this._duration;
|
||||
}
|
||||
|
||||
syncPlaybackRate(value) {
|
||||
let video = this._video;
|
||||
if(video && value !== video.playbackRate) {
|
||||
if (value === 0.5 | value === 0.8 |value === 1.0 |value === 1.25 | value === 1.5) {
|
||||
if (video && value !== video.playbackRate) {
|
||||
if (value === 0.5 | value === 0.8 | value === 1.0 | value === 1.25 | value === 1.5) {
|
||||
video.playbackRate = value;
|
||||
} else {
|
||||
console.warn('The platform does not support this PlaybackRate!');
|
||||
@@ -262,11 +262,11 @@ if (cc.internal.VideoPlayer) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
currentTime () {
|
||||
currentTime() {
|
||||
return this._currentTime;
|
||||
}
|
||||
|
||||
seekTo (time) {
|
||||
seekTo(time) {
|
||||
let video = this._video;
|
||||
if (!video || !this._loaded) return;
|
||||
video.seek(time);
|
||||
@@ -289,7 +289,7 @@ if (cc.internal.VideoPlayer) {
|
||||
}
|
||||
}
|
||||
|
||||
canPlay () {
|
||||
canPlay() {
|
||||
this._video.play();
|
||||
this.syncCurrentTime();
|
||||
}
|
||||
@@ -330,7 +330,7 @@ if (cc.internal.VideoPlayer) {
|
||||
}
|
||||
}
|
||||
|
||||
setFullScreenEnabled (enable) {
|
||||
setFullScreenEnabled(enable) {
|
||||
let video = this._video;
|
||||
if (!video || this._fullScreenEnabled === enable) {
|
||||
return;
|
||||
@@ -352,7 +352,7 @@ if (cc.internal.VideoPlayer) {
|
||||
// DO NOTHING...
|
||||
}
|
||||
|
||||
_getInitRect () {
|
||||
_getInitRect() {
|
||||
if (!this._component || !this._uiTrans) return;
|
||||
|
||||
const camera = this.UICamera;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
let sysInfo = jsb.getSystemInfoSync();
|
||||
jsb._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
ral._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
let sysInfo = jsb.getSystemInfoSync();
|
||||
jsb._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
ral._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
let sysInfo = jsb.getSystemInfoSync();
|
||||
jsb._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
ral._isLandscape = sysInfo.screenWidth > sysInfo.screenHeight;
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user