@galacean/effects-plugin-multimedia 2.8.8 → 2.9.0-alpha.0
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/dist/index.js +64 -18
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +64 -18
- package/dist/index.mjs.map +1 -1
- package/dist/video/video-component.d.ts +8 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player multimedia plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.
|
|
6
|
+
* Version: v2.9.0-alpha.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -630,20 +630,26 @@ var VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
630
630
|
};
|
|
631
631
|
_proto.onAwake = function onAwake() {
|
|
632
632
|
var _this = this;
|
|
633
|
-
var _this_item_composition, _this_item_composition1, _this_item_composition2;
|
|
634
633
|
MaskableGraphic.prototype.onAwake.call(this);
|
|
635
|
-
|
|
634
|
+
var composition = this.item.composition;
|
|
635
|
+
if (!composition) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
this.handleGoto = function(option) {
|
|
636
639
|
_this.setCurrentTime(_this.item.time);
|
|
637
|
-
}
|
|
638
|
-
|
|
640
|
+
};
|
|
641
|
+
this.handlePause = function() {
|
|
639
642
|
_this.pauseVideo();
|
|
640
|
-
}
|
|
641
|
-
|
|
643
|
+
};
|
|
644
|
+
this.handlePlay = function(option) {
|
|
642
645
|
if (_this.item.time < 0) {
|
|
643
646
|
return;
|
|
644
647
|
}
|
|
645
648
|
_this.playVideo();
|
|
646
|
-
}
|
|
649
|
+
};
|
|
650
|
+
composition.on("goto", this.handleGoto);
|
|
651
|
+
composition.on("pause", this.handlePause);
|
|
652
|
+
composition.on("play", this.handlePlay);
|
|
647
653
|
};
|
|
648
654
|
_proto.fromData = function fromData(data) {
|
|
649
655
|
MaskableGraphic.prototype.fromData.call(this, data);
|
|
@@ -687,13 +693,13 @@ var VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
687
693
|
var _this_item = this.item, videoTime = _this_item.time, videoDuration = _this_item.duration, videoEndBehavior = _this_item.endBehavior, composition = _this_item.composition;
|
|
688
694
|
assertExist(composition);
|
|
689
695
|
var _composition_rootItem = composition.rootItem, rootEndBehavior = _composition_rootItem.endBehavior, rootDuration = _composition_rootItem.duration;
|
|
690
|
-
//
|
|
696
|
+
// 判断是否处于"结束状态":
|
|
691
697
|
// - 视频时间为 0(未开始)
|
|
692
698
|
// - 合成时间已达最大时长(播放完毕)
|
|
693
699
|
// - 视频时间接近或等于其总时长(考虑容差阈值)
|
|
694
|
-
var isEnd = videoTime === 0 || composition.time
|
|
695
|
-
//
|
|
696
|
-
if (videoTime
|
|
700
|
+
var isEnd = videoTime === 0 || Math.abs(composition.time - rootDuration) <= this.threshold || Math.abs(videoTime - videoDuration) <= this.threshold;
|
|
701
|
+
// 如果视频时间大于等于 0,且未到结束状态,并且尚未触发播放,则开始播放视频
|
|
702
|
+
if (videoTime >= 0 && !isEnd && !this.played && this.isVideoActive) {
|
|
697
703
|
this.playVideo();
|
|
698
704
|
}
|
|
699
705
|
// 当视频播放时间接近或超过其总时长时,根据其结束行为进行处理
|
|
@@ -704,10 +710,6 @@ var VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
704
710
|
this.pauseVideo();
|
|
705
711
|
}
|
|
706
712
|
}
|
|
707
|
-
// ios freeze issue
|
|
708
|
-
// else if (videoEndBehavior === spec.EndBehavior.destroy || videoEndBehavior === spec.EndBehavior.restart) {
|
|
709
|
-
// this.setCurrentTime(0);
|
|
710
|
-
// }
|
|
711
713
|
}
|
|
712
714
|
// 判断整个合成是否接近播放完成
|
|
713
715
|
// composition.time + threshold >= rootDuration 表示即将结束
|
|
@@ -767,6 +769,20 @@ var VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
767
769
|
}
|
|
768
770
|
};
|
|
769
771
|
/**
|
|
772
|
+
* 设置当前视频是否为透明视频
|
|
773
|
+
* @param transparent 是否为透明视频
|
|
774
|
+
*/ _proto.setTransparent = function setTransparent(transparent) {
|
|
775
|
+
if (this.transparent === transparent) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
if (transparent) {
|
|
779
|
+
this.material.enableMacro("TRANSPARENT_VIDEO", true);
|
|
780
|
+
} else {
|
|
781
|
+
this.material.disableMacro("TRANSPARENT_VIDEO");
|
|
782
|
+
}
|
|
783
|
+
this.transparent = transparent;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
770
786
|
* 设置视频播放速率
|
|
771
787
|
* @param rate 视频播放速率
|
|
772
788
|
*/ _proto.setPlaybackRate = function setPlaybackRate(rate) {
|
|
@@ -824,15 +840,40 @@ var VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
824
840
|
this.video.pause();
|
|
825
841
|
};
|
|
826
842
|
_proto.onDestroy = function onDestroy() {
|
|
843
|
+
var _this_item;
|
|
827
844
|
MaskableGraphic.prototype.onDestroy.call(this);
|
|
845
|
+
// 清理播放状态
|
|
828
846
|
this.played = false;
|
|
829
847
|
this.isPlayLoading = false;
|
|
830
848
|
this.pendingPause = false;
|
|
849
|
+
this.isVideoActive = false;
|
|
850
|
+
// 清理video资源
|
|
831
851
|
if (this.video) {
|
|
852
|
+
// 暂停视频
|
|
832
853
|
this.video.pause();
|
|
833
|
-
|
|
854
|
+
// 移除video源,帮助垃圾回收
|
|
855
|
+
this.video.removeAttribute("src");
|
|
834
856
|
this.video.load();
|
|
857
|
+
// 清理video引用
|
|
858
|
+
this.video = undefined;
|
|
835
859
|
}
|
|
860
|
+
// 清理事件监听
|
|
861
|
+
var composition = (_this_item = this.item) == null ? void 0 : _this_item.composition;
|
|
862
|
+
if (composition) {
|
|
863
|
+
if (this.handleGoto) {
|
|
864
|
+
composition.off("goto", this.handleGoto);
|
|
865
|
+
}
|
|
866
|
+
if (this.handlePause) {
|
|
867
|
+
composition.off("pause", this.handlePause);
|
|
868
|
+
}
|
|
869
|
+
if (this.handlePlay) {
|
|
870
|
+
composition.off("play", this.handlePlay);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
// 清理处理器引用
|
|
874
|
+
this.handleGoto = undefined;
|
|
875
|
+
this.handlePause = undefined;
|
|
876
|
+
this.handlePlay = undefined;
|
|
836
877
|
};
|
|
837
878
|
_proto.onDisable = function onDisable() {
|
|
838
879
|
MaskableGraphic.prototype.onDisable.call(this);
|
|
@@ -842,6 +883,11 @@ var VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
842
883
|
_proto.onEnable = function onEnable() {
|
|
843
884
|
MaskableGraphic.prototype.onEnable.call(this);
|
|
844
885
|
this.isVideoActive = true;
|
|
886
|
+
this.played = false;
|
|
887
|
+
// 重播时确保视频同步到当前时间
|
|
888
|
+
if (this.video && this.item.composition) {
|
|
889
|
+
this.setCurrentTime(Math.max(0, this.item.time));
|
|
890
|
+
}
|
|
845
891
|
this.playVideo();
|
|
846
892
|
};
|
|
847
893
|
return VideoComponent;
|
|
@@ -1189,7 +1235,7 @@ AudioComponent = __decorate([
|
|
|
1189
1235
|
|
|
1190
1236
|
/**
|
|
1191
1237
|
* 插件版本号
|
|
1192
|
-
*/ var version = "2.
|
|
1238
|
+
*/ var version = "2.9.0-alpha.0";
|
|
1193
1239
|
registerPlugin("video", VideoLoader);
|
|
1194
1240
|
registerPlugin("audio", AudioLoader);
|
|
1195
1241
|
logger.info("Plugin multimedia version: " + version + ".");
|