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

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,17 @@
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 将视频元件还原为在组态外渲染,并且在弹窗时隐藏视频
400
+
401
+ ## 3.0.0-alpha.89(2023-06-01)
402
+ ### Web端
403
+ #### Bug Fix
404
+ 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,11 @@ class view_operation_element_ViewOperationElement extends conditional_enable_ele
39320
39323
  }
39321
39324
  closeView() {
39322
39325
  this.popupViewService.closeView();
39326
+ if ($(`#${this.hostContainerId} svg`).length === 1) {
39327
+ $(`#${this.hostContainerId} .video-hidden`)
39328
+ .removeClass('video-hidden')
39329
+ .css('visibility', 'visible');
39330
+ }
39323
39331
  this.recordViewOperation();
39324
39332
  }
39325
39333
  moveView(movementX, movementY) {
@@ -39501,88 +39509,64 @@ class video_element_VideoElement extends conditional_display_element_Conditional
39501
39509
  return;
39502
39510
  }
39503
39511
  this.videoId = guid["a" /* Guid */].newGuid().toString('n');
39512
+ this.rootElement.append('rect').attr('id', 'rect' + this.videoId).attr('fill', 'transparent')
39513
+ .attr('width', this.model.size.width)
39514
+ .attr('height', this.model.size.height);
39504
39515
  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;
39516
+ this.initVideo(result.url, result.isMobileType, this.videoId);
39517
+ }).catch(() => {
39518
+ throw new Error('Failure of the videoService');
39519
+ });
39520
+ }
39521
+ initVideo(videoUrl, isMobileType, videoId) {
39522
+ const patt = /https:.+.m3u8/;
39523
+ if (videoUrl.indexOf('http:') !== -1) {
39524
+ videoUrl = videoUrl.replace('http:', 'https:');
39525
+ }
39526
+ if (!patt.test(videoUrl)) {
39527
+ let videoToolTip = this.localization.invalidVideoAddress;
39528
+ if (Object(lodash["isNil"])(videoUrl) || videoUrl === '') {
39529
+ videoToolTip = this.localization.unconfiguredVideoAddress;
39520
39530
  }
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);
39531
+ this.addVideoAddressToolTip(videoToolTip);
39532
+ return;
39533
+ }
39534
+ const currentRect = this.$element.find('rect#rect' + videoId).first();
39535
+ if (!currentRect.length) {
39536
+ return;
39537
+ }
39538
+ const clientRect = currentRect[0].getBoundingClientRect();
39539
+ const chartWidth = clientRect.width;
39540
+ const chartHeight = clientRect.height;
39541
+ const left = this.model.location.x / this.guiSize.width * $('.' + this.svgRootClass).find('.svg-content').width();
39542
+ const top = this.model.location.y / this.guiSize.height * $('.' + this.svgRootClass).find('.svg-content').height();
39543
+ let videoHtml = `<video scareX="${this.model.location.x / this.guiSize.width}"
39544
+ scareY="${this.model.location.y / this.guiSize.height}" id="${videoId}" src="${videoUrl}" style="
39545
+ position: absolute;top:${top}px;left:${left}px;width:${chartWidth}px;height:${chartHeight}px;object-fit:fill;z-index:0"
39546
+ playsInline webkit-playsinline `;
39547
+ const isAndroid = !!navigator.userAgent.match(/(Android)/i);
39548
+ if (this.isMobileMode) {
39549
+ if (isAndroid) {
39550
+ if (isMobileType) {
39551
+ videoHtml += ' controls ';
39543
39552
  }
39553
+ videoHtml += ' autoplay muted></video>';
39544
39554
  }
39545
39555
  else {
39546
- video.attr('autoplay', true);
39547
- }
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);
39556
+ videoHtml += ' controls muted></video>';
39582
39557
  }
39583
- }).catch(() => {
39584
- throw new Error('Failure of the videoService');
39585
- });
39558
+ }
39559
+ else {
39560
+ videoHtml += ' controls autoplay muted></video>';
39561
+ }
39562
+ $('.' + this.svgRootClass).find('.svg-content').append(videoHtml);
39563
+ if (this.isShow === false) {
39564
+ $('#' + this.videoId).hide();
39565
+ }
39566
+ this.videoPlayer = new EZUIPlayer(videoId);
39567
+ if (isAndroid && !isMobileType) {
39568
+ this.setAndroidVideo(videoId);
39569
+ }
39586
39570
  }
39587
39571
  addVideoAddressToolTip(videoToolTip) {
39588
39572
  const size = this.model.size;
@@ -39604,50 +39588,35 @@ class video_element_VideoElement extends conditional_display_element_Conditional
39604
39588
  const textElement = new text_element_TextElementModal(videoToolTip, font, size.width, size.height);
39605
39589
  this.$element.append(textElement.Element);
39606
39590
  }
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();
39591
+ setAndroidVideo(videoId) {
39592
+ let isFullscreen = false;
39593
+ const videoElement = $('#' + videoId);
39594
+ let preHeight = videoElement.height();
39595
+ let preWidth = videoElement.width();
39596
+ let preTop = videoElement.css('top');
39597
+ let preLeft = videoElement.css('left');
39598
+ videoElement.on('click', () => {
39599
+ if (!isFullscreen) {
39600
+ preHeight = videoElement.height();
39601
+ preWidth = videoElement.width();
39602
+ preTop = videoElement.css('top');
39603
+ preLeft = videoElement.css('left');
39604
+ const width = document.body.clientWidth;
39605
+ const height = width * 9 / 16;
39606
+ videoElement.css('width', width + 'px');
39607
+ videoElement.css('height', height + 'px');
39608
+ videoElement.css('left', '0px');
39609
+ videoElement.css('top', '0px');
39610
+ videoElement.css('z-index', '99');
39611
+ isFullscreen = true;
39631
39612
  }
39632
39613
  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
- }
39614
+ videoElement.css('width', preWidth + 'px');
39615
+ videoElement.css('height', preHeight + 'px');
39616
+ videoElement.css('left', preLeft);
39617
+ videoElement.css('top', preTop);
39618
+ videoElement.css('z-index', '0');
39619
+ isFullscreen = false;
39651
39620
  }
39652
39621
  });
39653
39622
  }