@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.js
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
|
'use strict';
|
|
@@ -653,20 +653,26 @@ exports.VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
653
653
|
};
|
|
654
654
|
_proto.onAwake = function onAwake() {
|
|
655
655
|
var _this = this;
|
|
656
|
-
var _this_item_composition, _this_item_composition1, _this_item_composition2;
|
|
657
656
|
MaskableGraphic.prototype.onAwake.call(this);
|
|
658
|
-
|
|
657
|
+
var composition = this.item.composition;
|
|
658
|
+
if (!composition) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
this.handleGoto = function(option) {
|
|
659
662
|
_this.setCurrentTime(_this.item.time);
|
|
660
|
-
}
|
|
661
|
-
|
|
663
|
+
};
|
|
664
|
+
this.handlePause = function() {
|
|
662
665
|
_this.pauseVideo();
|
|
663
|
-
}
|
|
664
|
-
|
|
666
|
+
};
|
|
667
|
+
this.handlePlay = function(option) {
|
|
665
668
|
if (_this.item.time < 0) {
|
|
666
669
|
return;
|
|
667
670
|
}
|
|
668
671
|
_this.playVideo();
|
|
669
|
-
}
|
|
672
|
+
};
|
|
673
|
+
composition.on("goto", this.handleGoto);
|
|
674
|
+
composition.on("pause", this.handlePause);
|
|
675
|
+
composition.on("play", this.handlePlay);
|
|
670
676
|
};
|
|
671
677
|
_proto.fromData = function fromData(data) {
|
|
672
678
|
MaskableGraphic.prototype.fromData.call(this, data);
|
|
@@ -710,13 +716,13 @@ exports.VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
710
716
|
var _this_item = this.item, videoTime = _this_item.time, videoDuration = _this_item.duration, videoEndBehavior = _this_item.endBehavior, composition = _this_item.composition;
|
|
711
717
|
EFFECTS.assertExist(composition);
|
|
712
718
|
var _composition_rootItem = composition.rootItem, rootEndBehavior = _composition_rootItem.endBehavior, rootDuration = _composition_rootItem.duration;
|
|
713
|
-
//
|
|
719
|
+
// 判断是否处于"结束状态":
|
|
714
720
|
// - 视频时间为 0(未开始)
|
|
715
721
|
// - 合成时间已达最大时长(播放完毕)
|
|
716
722
|
// - 视频时间接近或等于其总时长(考虑容差阈值)
|
|
717
|
-
var isEnd = videoTime === 0 || composition.time
|
|
718
|
-
//
|
|
719
|
-
if (videoTime
|
|
723
|
+
var isEnd = videoTime === 0 || Math.abs(composition.time - rootDuration) <= this.threshold || Math.abs(videoTime - videoDuration) <= this.threshold;
|
|
724
|
+
// 如果视频时间大于等于 0,且未到结束状态,并且尚未触发播放,则开始播放视频
|
|
725
|
+
if (videoTime >= 0 && !isEnd && !this.played && this.isVideoActive) {
|
|
720
726
|
this.playVideo();
|
|
721
727
|
}
|
|
722
728
|
// 当视频播放时间接近或超过其总时长时,根据其结束行为进行处理
|
|
@@ -727,10 +733,6 @@ exports.VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
727
733
|
this.pauseVideo();
|
|
728
734
|
}
|
|
729
735
|
}
|
|
730
|
-
// ios freeze issue
|
|
731
|
-
// else if (videoEndBehavior === spec.EndBehavior.destroy || videoEndBehavior === spec.EndBehavior.restart) {
|
|
732
|
-
// this.setCurrentTime(0);
|
|
733
|
-
// }
|
|
734
736
|
}
|
|
735
737
|
// 判断整个合成是否接近播放完成
|
|
736
738
|
// composition.time + threshold >= rootDuration 表示即将结束
|
|
@@ -790,6 +792,20 @@ exports.VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
790
792
|
}
|
|
791
793
|
};
|
|
792
794
|
/**
|
|
795
|
+
* 设置当前视频是否为透明视频
|
|
796
|
+
* @param transparent 是否为透明视频
|
|
797
|
+
*/ _proto.setTransparent = function setTransparent(transparent) {
|
|
798
|
+
if (this.transparent === transparent) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (transparent) {
|
|
802
|
+
this.material.enableMacro("TRANSPARENT_VIDEO", true);
|
|
803
|
+
} else {
|
|
804
|
+
this.material.disableMacro("TRANSPARENT_VIDEO");
|
|
805
|
+
}
|
|
806
|
+
this.transparent = transparent;
|
|
807
|
+
};
|
|
808
|
+
/**
|
|
793
809
|
* 设置视频播放速率
|
|
794
810
|
* @param rate 视频播放速率
|
|
795
811
|
*/ _proto.setPlaybackRate = function setPlaybackRate(rate) {
|
|
@@ -847,15 +863,40 @@ exports.VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
847
863
|
this.video.pause();
|
|
848
864
|
};
|
|
849
865
|
_proto.onDestroy = function onDestroy() {
|
|
866
|
+
var _this_item;
|
|
850
867
|
MaskableGraphic.prototype.onDestroy.call(this);
|
|
868
|
+
// 清理播放状态
|
|
851
869
|
this.played = false;
|
|
852
870
|
this.isPlayLoading = false;
|
|
853
871
|
this.pendingPause = false;
|
|
872
|
+
this.isVideoActive = false;
|
|
873
|
+
// 清理video资源
|
|
854
874
|
if (this.video) {
|
|
875
|
+
// 暂停视频
|
|
855
876
|
this.video.pause();
|
|
856
|
-
|
|
877
|
+
// 移除video源,帮助垃圾回收
|
|
878
|
+
this.video.removeAttribute("src");
|
|
857
879
|
this.video.load();
|
|
880
|
+
// 清理video引用
|
|
881
|
+
this.video = undefined;
|
|
858
882
|
}
|
|
883
|
+
// 清理事件监听
|
|
884
|
+
var composition = (_this_item = this.item) == null ? void 0 : _this_item.composition;
|
|
885
|
+
if (composition) {
|
|
886
|
+
if (this.handleGoto) {
|
|
887
|
+
composition.off("goto", this.handleGoto);
|
|
888
|
+
}
|
|
889
|
+
if (this.handlePause) {
|
|
890
|
+
composition.off("pause", this.handlePause);
|
|
891
|
+
}
|
|
892
|
+
if (this.handlePlay) {
|
|
893
|
+
composition.off("play", this.handlePlay);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
// 清理处理器引用
|
|
897
|
+
this.handleGoto = undefined;
|
|
898
|
+
this.handlePause = undefined;
|
|
899
|
+
this.handlePlay = undefined;
|
|
859
900
|
};
|
|
860
901
|
_proto.onDisable = function onDisable() {
|
|
861
902
|
MaskableGraphic.prototype.onDisable.call(this);
|
|
@@ -865,6 +906,11 @@ exports.VideoComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
865
906
|
_proto.onEnable = function onEnable() {
|
|
866
907
|
MaskableGraphic.prototype.onEnable.call(this);
|
|
867
908
|
this.isVideoActive = true;
|
|
909
|
+
this.played = false;
|
|
910
|
+
// 重播时确保视频同步到当前时间
|
|
911
|
+
if (this.video && this.item.composition) {
|
|
912
|
+
this.setCurrentTime(Math.max(0, this.item.time));
|
|
913
|
+
}
|
|
868
914
|
this.playVideo();
|
|
869
915
|
};
|
|
870
916
|
return VideoComponent;
|
|
@@ -1212,7 +1258,7 @@ exports.AudioComponent = __decorate([
|
|
|
1212
1258
|
|
|
1213
1259
|
/**
|
|
1214
1260
|
* 插件版本号
|
|
1215
|
-
*/ var version = "2.
|
|
1261
|
+
*/ var version = "2.9.0-alpha.0";
|
|
1216
1262
|
EFFECTS.registerPlugin("video", VideoLoader);
|
|
1217
1263
|
EFFECTS.registerPlugin("audio", AudioLoader);
|
|
1218
1264
|
EFFECTS.logger.info("Plugin multimedia version: " + version + ".");
|