|
1221 | 1221 | EZUIKitPlayer.prototype.fullScreen = function () { |
1222 | 1222 | var id = 'EZUIKitPlayer-' + this.opt.id; |
1223 | 1223 | var player = document.getElementById(id).contentWindow; |
1224 | | - var requestFullScreen = function (element) { |
1225 | | - var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; |
1226 | | - if (requestMethod) { |
1227 | | - requestMethod.call(element); |
1228 | | - } else if (typeof window.ActiveXObject !== "undefined") { |
1229 | | - var wscript = new ActiveXObject("WScript.Shell"); |
1230 | | - if (wscript !== null) { |
1231 | | - wscript.SendKeys("{F11}"); |
1232 | | - } |
| 1224 | + if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) { |
| 1225 | + // console.log('移动端全屏'); |
| 1226 | + let width = document.documentElement.clientWidth; |
| 1227 | + let height = document.documentElement.clientHeight; |
| 1228 | + // wrapper = document.getElementById("test"), |
| 1229 | + let wrapper = document.body;//document.body 属性返回 <body> 元素, document.documentElement 属性返回 <html> 元素。 |
| 1230 | + wrapper =document.getElementById(id); |
| 1231 | + let style = ""; |
| 1232 | + if (width >= height) { // 竖屏 |
| 1233 | + style += "width:" + width + "px;"; |
| 1234 | + style += "height:" + height + "px;"; |
| 1235 | + style += "-webkit-transform: rotate(0); transform: rotate(0);"; |
| 1236 | + style += "-webkit-transform-origin: 0 0;"; |
| 1237 | + style += "transform-origin: 0 0;"; |
| 1238 | + } else { // 横屏 |
| 1239 | + style += "width:" + height + "px;";// 注意旋转后的宽高切换 |
| 1240 | + style += "height:" + width + "px;"; |
| 1241 | + style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);"; |
| 1242 | + // 注意旋转中点的处理 |
| 1243 | + style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;"; |
| 1244 | + style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;"; |
1233 | 1245 | } |
| 1246 | + style += 'position: fixed;top: 0;left: 0;z-index:10'; |
| 1247 | + wrapper.style.cssText = style; |
| 1248 | + setTimeout(function () { |
| 1249 | + player.postMessage({ |
| 1250 | + action:'reSize', |
| 1251 | + width: Math.max(width,height), |
| 1252 | + height: Math.min(width,height), |
| 1253 | + }, domain + "/ezopen/h5/iframe") |
| 1254 | + }, 200) |
| 1255 | + |
| 1256 | + } else { |
| 1257 | + // console.log('pc端全屏'); |
| 1258 | + var requestFullScreen = function (element) { |
| 1259 | + var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; |
| 1260 | + if (requestMethod) { |
| 1261 | + requestMethod.call(element); |
| 1262 | + } else if (typeof window.ActiveXObject !== "undefined") { |
| 1263 | + var wscript = new ActiveXObject("WScript.Shell"); |
| 1264 | + if (wscript !== null) { |
| 1265 | + wscript.SendKeys("{F11}"); |
| 1266 | + } |
| 1267 | + } |
| 1268 | + } |
| 1269 | + requestFullScreen(document.getElementById(id)); |
| 1270 | + setTimeout(function () { |
| 1271 | + player.postMessage("autoResize", domain + "/ezopen/h5/iframe") |
| 1272 | + }, 200) |
1234 | 1273 | } |
1235 | | - requestFullScreen(document.getElementById(id)); |
1236 | | - setTimeout(function () { |
1237 | | - player.postMessage("autoResize", domain + "/ezopen/h5/iframe") |
1238 | | - }, 100) |
1239 | 1274 | }; |
| 1275 | + EZUIKitPlayer.prototype.cancelFullScreen = function () { |
| 1276 | + var id = 'EZUIKitPlayer-' + this.opt.id; |
| 1277 | + var player = document.getElementById(id).contentWindow; |
| 1278 | + if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) { |
| 1279 | + let width = document.getElementById(id).width; |
| 1280 | + let height = document.getElementById(id).height; |
| 1281 | + // wrapper = document.getElementById("test"), |
| 1282 | + let wrapper = document.body;//document.body 属性返回 <body> 元素, document.documentElement 属性返回 <html> 元素。 |
| 1283 | + wrapper =document.getElementById(id); |
| 1284 | + let style = ""; |
| 1285 | + if (width >= height) { // 竖屏 |
| 1286 | + style += "width:" + width + "px;"; |
| 1287 | + style += "height:" + height + "px;"; |
| 1288 | + style += "-webkit-transform: rotate(0); transform: rotate(0);"; |
| 1289 | + style += "-webkit-transform-origin: 0 0;"; |
| 1290 | + style += "transform-origin: 0 0;"; |
| 1291 | + } else { // 横屏 |
| 1292 | + style += "width:" + height + "px;";// 注意旋转后的宽高切换 |
| 1293 | + style += "height:" + width + "px;"; |
| 1294 | + style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);"; |
| 1295 | + // 注意旋转中点的处理 |
| 1296 | + style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;"; |
| 1297 | + style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;"; |
| 1298 | + } |
| 1299 | + wrapper.style.cssText = style; |
| 1300 | + setTimeout(function () { |
| 1301 | + player.postMessage({ |
| 1302 | + action:'reSize', |
| 1303 | + width: width, |
| 1304 | + height: height, |
| 1305 | + }, domain + "/ezopen/h5/iframe") |
| 1306 | + }, 200) |
| 1307 | + } else { |
| 1308 | + if (document.exitFullscreen) { |
| 1309 | + document.exitFullscreen(); |
| 1310 | + } else if (document.webkitCancelFullScreen) { |
| 1311 | + document.webkitCancelFullScreen(); |
| 1312 | + } else if (document.mozCancelFullScreen) { |
| 1313 | + document.mozCancelFullScreen(); |
| 1314 | + } |
| 1315 | + } |
| 1316 | + } |
1240 | 1317 |
|
1241 | 1318 | EZUIKitPlayer.prototype.capturePicture = function (fileName,isUndownload) { |
1242 | 1319 | var id = 'EZUIKitPlayer-' + this.opt.id; |
|
0 commit comments