@flexem/fc-gui 3.0.0-alpha.87 → 3.0.0-alpha.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -388,7 +388,12 @@
388
388
  #### Bug Fix
389
389
  1. FLEXCLOUD-2612 组态元件写值超时
390
390
 
391
- ## 3.0.0-alpha.8(2023-05-31)
391
+ ## 3.0.0-alpha.87(2023-05-31)
392
392
  ### Web端
393
393
  #### Bug Fix
394
- 1. FLEXCLOUD-2698 【app-ios】视频元件放大后缩小不应占满整个组态
394
+ 1. FLEXCLOUD-2698 【app-ios】视频元件放大后缩小不应占满整个组态
395
+
396
+ ## 3.0.0-alpha.88(2023-06-01)
397
+ ### Web端
398
+ #### Bug Fix
399
+ 1. FLEXCLOUD-2699、FLEXCLOUD-2700 将视频元件还原为在组态外渲染,并且在弹窗时隐藏视频
@@ -39313,6 +39313,9 @@ class view_operation_element_ViewOperationElement extends conditional_enable_ele
39313
39313
  const viewIndex = this.model.viewIndex;
39314
39314
  if (null != viewIndex) {
39315
39315
  this.popupViewService.popView(viewIndex, this.hostContainerId, this.el).subscribe(() => this.recordViewOperation(), error => this.logger.error(`ToggleView(${viewIndex}) failed. ${error}`));
39316
+ $(`#${this.hostContainerId} video`)
39317
+ .addClass('video-hidden')
39318
+ .css('visibility', 'hidden');
39316
39319
  }
39317
39320
  else {
39318
39321
  this.logger.error('[GUI]Toggle View:invalid view index');
@@ -39320,6 +39323,9 @@ class view_operation_element_ViewOperationElement extends conditional_enable_ele
39320
39323
  }
39321
39324
  closeView() {
39322
39325
  this.popupViewService.closeView();
39326
+ $(`#${this.hostContainerId} .video-hidden`)
39327
+ .removeClass('video-hidden')
39328
+ .css('visibility', 'visible');
39323
39329
  this.recordViewOperation();
39324
39330
  }
39325
39331
  moveView(movementX, movementY) {
@@ -39501,88 +39507,64 @@ class video_element_VideoElement extends conditional_display_element_Conditional
39501
39507
  return;
39502
39508
  }
39503
39509
  this.videoId = guid["a" /* Guid */].newGuid().toString('n');
39510
+ this.rootElement.append('rect').attr('id', 'rect' + this.videoId).attr('fill', 'transparent')
39511
+ .attr('width', this.model.size.width)
39512
+ .attr('height', this.model.size.height);
39504
39513
  this.videoService.getVideoUrl(this.model.videoTag).then(result => {
39505
- this.isMobileType = result.isMobileType;
39506
- const isAndroid = !!navigator.userAgent.match(/(Android)/i);
39507
- const isIos = !!navigator.userAgent.match(/(Mac)/i);
39508
- let videoUrl = result.url;
39509
- const patt = /https:.+.m3u8/;
39510
- if (videoUrl.indexOf('http:') !== -1) {
39511
- videoUrl = videoUrl.replace('http:', 'https:');
39512
- }
39513
- if (!patt.test(videoUrl)) {
39514
- let videoToolTip = this.localization.invalidVideoAddress;
39515
- if (Object(lodash["isNil"])(videoUrl) || videoUrl === '') {
39516
- videoToolTip = this.localization.unconfiguredVideoAddress;
39517
- }
39518
- this.addVideoAddressToolTip(videoToolTip);
39519
- return;
39514
+ this.initVideo(result.url, result.isMobileType, this.videoId);
39515
+ }).catch(() => {
39516
+ throw new Error('Failure of the videoService');
39517
+ });
39518
+ }
39519
+ initVideo(videoUrl, isMobileType, videoId) {
39520
+ const patt = /https:.+.m3u8/;
39521
+ if (videoUrl.indexOf('http:') !== -1) {
39522
+ videoUrl = videoUrl.replace('http:', 'https:');
39523
+ }
39524
+ if (!patt.test(videoUrl)) {
39525
+ let videoToolTip = this.localization.invalidVideoAddress;
39526
+ if (Object(lodash["isNil"])(videoUrl) || videoUrl === '') {
39527
+ videoToolTip = this.localization.unconfiguredVideoAddress;
39520
39528
  }
39521
- this.rootElement.attr('id', this.videoId + '-box');
39522
- const video = this.rootElement.append('foreignObject')
39523
- .attr('x', 0)
39524
- .attr('y', 0)
39525
- .attr('width', this.model.size.width)
39526
- .attr('height', this.model.size.height)
39527
- .append('xhtml:video')
39528
- .attr('id', this.videoId)
39529
- .attr('class', 'element-video')
39530
- .attr('scareX', this.model.location.x / this.guiSize.width)
39531
- .attr('scareY', this.model.location.y / this.guiSize.height)
39532
- .attr('src', videoUrl)
39533
- .style('width', '100%')
39534
- .style('height', '100%')
39535
- .style('object-fit', 'fill')
39536
- .attr('playsInline', true)
39537
- .attr('webkit-playsinline', true)
39538
- .attr('controls', true)
39539
- .attr('muted', true);
39540
- if (this.isMobileMode) {
39541
- if (isAndroid) {
39542
- video.attr('autoplay', true);
39529
+ this.addVideoAddressToolTip(videoToolTip);
39530
+ return;
39531
+ }
39532
+ const currentRect = this.$element.find('rect#rect' + videoId).first();
39533
+ if (!currentRect.length) {
39534
+ return;
39535
+ }
39536
+ const clientRect = currentRect[0].getBoundingClientRect();
39537
+ const chartWidth = clientRect.width;
39538
+ const chartHeight = clientRect.height;
39539
+ const left = this.model.location.x / this.guiSize.width * $('.' + this.svgRootClass).find('.svg-content').width();
39540
+ const top = this.model.location.y / this.guiSize.height * $('.' + this.svgRootClass).find('.svg-content').height();
39541
+ let videoHtml = `<video scareX="${this.model.location.x / this.guiSize.width}"
39542
+ scareY="${this.model.location.y / this.guiSize.height}" id="${videoId}" src="${videoUrl}" style="
39543
+ position: absolute;top:${top}px;left:${left}px;width:${chartWidth}px;height:${chartHeight}px;object-fit:fill;z-index:0"
39544
+ playsInline webkit-playsinline `;
39545
+ const isAndroid = !!navigator.userAgent.match(/(Android)/i);
39546
+ if (this.isMobileMode) {
39547
+ if (isAndroid) {
39548
+ if (isMobileType) {
39549
+ videoHtml += ' controls ';
39543
39550
  }
39551
+ videoHtml += ' autoplay muted></video>';
39544
39552
  }
39545
39553
  else {
39546
- video.attr('autoplay', true);
39554
+ videoHtml += ' controls muted></video>';
39547
39555
  }
39548
- if (this.isShow === false) {
39549
- $('#' + this.videoId).hide();
39550
- }
39551
- if (isIos) {
39552
- const gElement = document.getElementById(this.videoId + '-box');
39553
- this.clientRect = this.clientRect || gElement.getBoundingClientRect();
39554
- const svgElement = document.querySelector('.svg-content > svg');
39555
- const svgClientRect = svgElement.getBoundingClientRect();
39556
- svgElement.style.overflow = 'visible';
39557
- const x = svgElement.clientWidth / this.clientRect.width;
39558
- const y = svgElement.clientHeight / this.clientRect.height;
39559
- this.rootElement.style('transform', `scale(${x}, ${y})`);
39560
- this.rootElement.style('transform-origin', 'left top');
39561
- video.style('z-index', 0);
39562
- setTimeout(() => {
39563
- this.videoClientRect = document.getElementById(this.videoId).getBoundingClientRect();
39564
- video.style('position', 'absolute');
39565
- video.style('left', this.clientRect.left + 'px');
39566
- video.style('top', this.clientRect.top - svgClientRect.top + 'px');
39567
- video.style('transform', `scale(${this.clientRect.width / this.videoClientRect.width}, ${this.clientRect.height / this.videoClientRect.height})`);
39568
- video.style('transform-origin', 'left top');
39569
- }, 300);
39570
- $('#' + this.videoId).bind('webkitendfullscreen', () => {
39571
- setTimeout(() => {
39572
- video.style('width', this.videoClientRect.width + 'px');
39573
- video.style('height', this.videoClientRect.height + 'px');
39574
- }, 1000);
39575
- });
39576
- }
39577
- this.videoPlayer = new EZUIPlayer(this.videoId);
39578
- if (isAndroid) {
39579
- setTimeout(() => {
39580
- this.setAndroidVideo();
39581
- }, 500);
39582
- }
39583
- }).catch(() => {
39584
- throw new Error('Failure of the videoService');
39585
- });
39556
+ }
39557
+ else {
39558
+ videoHtml += ' controls autoplay muted></video>';
39559
+ }
39560
+ $('.' + this.svgRootClass).find('.svg-content').append(videoHtml);
39561
+ if (this.isShow === false) {
39562
+ $('#' + this.videoId).hide();
39563
+ }
39564
+ this.videoPlayer = new EZUIPlayer(videoId);
39565
+ if (isAndroid && !isMobileType) {
39566
+ this.setAndroidVideo(videoId);
39567
+ }
39586
39568
  }
39587
39569
  addVideoAddressToolTip(videoToolTip) {
39588
39570
  const size = this.model.size;
@@ -39604,50 +39586,35 @@ class video_element_VideoElement extends conditional_display_element_Conditional
39604
39586
  const textElement = new text_element_TextElementModal(videoToolTip, font, size.width, size.height);
39605
39587
  this.$element.append(textElement.Element);
39606
39588
  }
39607
- setAndroidVideo() {
39608
- const { StatusBar } = window;
39609
- this.bindFullscreenEvent();
39610
- window.addEventListener('orientationchange', () => {
39611
- StatusBar.show();
39612
- this.hide();
39613
- clearTimeout(this.refreshTimer);
39614
- this.refreshTimer = null;
39615
- this.refreshTimer = setTimeout(() => {
39616
- this.init();
39617
- this.show();
39618
- }, 1000);
39619
- });
39620
- }
39621
- bindFullscreenEvent() {
39622
- const that = this;
39623
- const { StatusBar } = window;
39624
- $('#' + this.videoId).bind('webkitfullscreenchange', () => {
39625
- if (document.webkitIsFullScreen) {
39626
- $('#' + that.videoId).css({
39627
- 'object-fit': 'contain',
39628
- 'z-index': 99
39629
- });
39630
- StatusBar.hide();
39589
+ setAndroidVideo(videoId) {
39590
+ let isFullscreen = false;
39591
+ const videoElement = $('#' + videoId);
39592
+ let preHeight = videoElement.height();
39593
+ let preWidth = videoElement.width();
39594
+ let preTop = videoElement.css('top');
39595
+ let preLeft = videoElement.css('left');
39596
+ videoElement.on('click', () => {
39597
+ if (!isFullscreen) {
39598
+ preHeight = videoElement.height();
39599
+ preWidth = videoElement.width();
39600
+ preTop = videoElement.css('top');
39601
+ preLeft = videoElement.css('left');
39602
+ const width = document.body.clientWidth;
39603
+ const height = width * 9 / 16;
39604
+ videoElement.css('width', width + 'px');
39605
+ videoElement.css('height', height + 'px');
39606
+ videoElement.css('left', '0px');
39607
+ videoElement.css('top', '0px');
39608
+ videoElement.css('z-index', '99');
39609
+ isFullscreen = true;
39631
39610
  }
39632
39611
  else {
39633
- StatusBar.show();
39634
- if (that.isMobileType) {
39635
- $('#' + this.videoId).css('object-fit', document.webkitIsFullScreen ? 'contain' : 'fill');
39636
- }
39637
- else {
39638
- clearTimeout(this.resetTimer);
39639
- this.resetTimer = null;
39640
- $('#' + this.videoId).css('display', 'none');
39641
- this.resetTimer = setTimeout(() => {
39642
- $('#' + this.videoId).css({
39643
- 'width': '100%',
39644
- 'height': '100%',
39645
- 'display': 'block',
39646
- 'z-index': 0,
39647
- 'object-fit': document.webkitIsFullScreen ? 'contain' : 'fill'
39648
- });
39649
- }, 1000);
39650
- }
39612
+ videoElement.css('width', preWidth + 'px');
39613
+ videoElement.css('height', preHeight + 'px');
39614
+ videoElement.css('left', preLeft);
39615
+ videoElement.css('top', preTop);
39616
+ videoElement.css('z-index', '0');
39617
+ isFullscreen = false;
39651
39618
  }
39652
39619
  });
39653
39620
  }