提交 7daffa30 编写于 作者: DCloud-yyl's avatar DCloud-yyl

Merge branch 'alpha'

# Conflicts:
#	uni_modules/uni-video/package.json
#	uni_modules/uni-video/utssdk/app-android/index.uts
#	uni_modules/uni-video/utssdk/app-android/index.vue
#	uni_modules/uni-video/utssdk/app-android/libs/videoplayer.aar
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/Info.plist
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/DCUniVideo
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/Headers/DCUniVideo-Swift.h
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/Info.plist
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios.abi.json
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios.private.swiftinterface
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios.swiftdoc
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios.swiftinterface
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/DCUniVideo
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Headers/DCUniVideo-Swift.h
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Info.plist
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.abi.json
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftdoc
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftinterface
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.abi.json
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftdoc
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftinterface
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/_CodeSignature/CodeDirectory
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/_CodeSignature/CodeRequirements-1
#	uni_modules/uni-video/utssdk/app-ios/frameworks/DCUniVideo.xcframework/ios-arm64_x86_64-simulator/DCUniVideo.framework/_CodeSignature/CodeResources
#	uni_modules/uni-video/utssdk/app-ios/index.vue
......@@ -32,7 +32,8 @@
},
"uni_modules": {
"dependencies": [
"uni-framework"
"uni-framework",
"uni-fileSystemManager"
],
"uni-ext-api": {
"uni": {
......
......@@ -7,7 +7,7 @@ export const createVideoContext : CreateVideoContext = function (videoId : strin
if (component == null) {
const pages = getCurrentPages();
if (pages.length > 0) {
videoElement = pages[pages.length - 1].$el?.parentNode?.querySelector('#' + videoId);
videoElement = pages[pages.length - 1].vm!.$el?.parentNode?.querySelector('#' + videoId);
}
} else {
videoElement = component.$el?.parentNode?.querySelector('#' + videoId);
......
......@@ -20,6 +20,8 @@
import ViewGroup from 'android.view.ViewGroup';
import OnHierarchyChangeListener from 'android.view.ViewGroup.OnHierarchyChangeListener';
import View from 'android.view.View';
import OnKeyListener from 'android.view.View.OnKeyListener';
import KeyEvent from 'android.view.KeyEvent';
import WindowManager from 'android.view.WindowManager';
import TextUtils from 'android.text.TextUtils';
import JSONObject from 'org.json.JSONObject';
......@@ -32,6 +34,8 @@
import Glide from 'com.bumptech.glide.Glide';
import File from 'java.io.File';
import { Danmu, RequestFullScreenOptions } from '../interface.uts';
import { UniVideoTimeUpdateEventDetail, UniVideoFullScreenChangeEventDetail, UniVideoProgressEventDetail, UniVideoFullScreenClickEventDetail, UniVideoControlsToggleEventDetail } from '../interface.uts';
import { UniVideoTimeUpdateEventImpl, UniVideoFullScreenChangeEventImpl, UniVideoErrorEventImpl, UniVideoProgressEventImpl, UniVideoFullScreenClickEventImpl, UniVideoControlsToggleEventImpl } from './event.uts';
......@@ -52,7 +56,8 @@
screenHeight: 0,
layoutWidth: 0,
layoutHeight: 0,
videoBox: null as FrameLayout | null
videoBox: null as FrameLayout | null,
copyPath: ''
};
},
emits: ["play", "pause", "ended", "timeupdate", "fullscreenchange", "waiting", "error", "progress", "fullscreenclick", "controlstoggle"],
......@@ -402,6 +407,9 @@
this.playerView?.setOnErrorListener(new OnErrorListenerImpl(this));
this.playerView?.setOnTextureRenderViewListener(new OnTextureRenderViewListenerImpl(this));
this.playerView?.setOnHierarchyChangeListener(new OnHierarchyChangeListenerImpl(this));
this.playerView?.setOnKeyListener(new OnKeyListenerImpl(this));
this.playerView?.setFocusable(true);
this.playerView?.setFocusableInTouchMode(true);
},
NVLayouted() {
if (!this.isFirstLayoutFinished) {
......@@ -421,9 +429,11 @@
if (isFullScreenChanged) {
isFullScreenChanged = false;
if (this.playerView!.isFullscreen()) {
this.playerView?.requestFocus();
if (this.getLayoutWidth() != this.screenHeight) this.setStyleWidth(this.screenHeight.toFloat());
if (this.getLayoutHeight() != this.screenWidth) this.setStyleHeight(this.screenWidth.toFloat());
} else {
this.playerView?.clearFocus();
if (this.getLayoutWidth() != this.layoutWidth) this.setStyleWidth(this.layoutWidth.toFloat());
if (this.getLayoutHeight() != this.layoutHeight) this.setStyleHeight(this.layoutHeight.toFloat());
}
......@@ -434,6 +444,10 @@
this.playerView?.onDestroy();
this.playerView = null;
}
if (!this.copyPath.isEmpty()) {
const file = new File(this.copyPath);
if (file.exists()) file.delete();
}
},
NVRecycler() {
this.playerView = this.$el;
......@@ -577,7 +591,21 @@
if (src.startsWith("https://") || src.startsWith("http://") || src.startsWith("rtmp://") || src.startsWith("rtsp://")) { // 网络地址
return src;
} else { // 本地地址
return UTSAndroid.convert2AbsFullPath(src);
const path = UTSAndroid.convert2AbsFullPath(src);
if (path.startsWith('/android_asset')) {
const destDirPath = UTSAndroid.getAppContext()!.getCacheDir().getAbsolutePath() + '/uni-net-cache/video/';
const destDir = new File(destDirPath);
if (!destDir.exists()) destDir.mkdirs();
const destFilePath = destDirPath + path.substring(path.lastIndexOf('/') + 1);
const destFile = new File(destFilePath);
if (!destFile.exists()) {
destFile.createNewFile();
uni.getFileSystemManager().copyFileSync(src, destFilePath);
}
this.copyPath = destFilePath;
return destFilePath;
}
return path;
}
},
/**
......@@ -604,6 +632,8 @@
this.playerView?.setOnBufferingUpdateListener(new OnBufferingUpdateListenerImpl(this));
this.playerView?.setOnErrorListener(new OnErrorListenerImpl(this));
this.playerView?.setOnTextureRenderViewListener(new OnTextureRenderViewListenerImpl(this));
this.playerView?.setOnHierarchyChangeListener(new OnHierarchyChangeListenerImpl(this));
this.playerView?.setOnKeyListener(new OnKeyListenerImpl(this));
}
}
}
......@@ -653,7 +683,13 @@
this.comp.$emit("fullscreenclick", new UniVideoFullScreenClickEventImpl(JSON.parse<UniVideoFullScreenClickEventDetail>(msg)!));
break;
case "controlstoggle":
this.comp.$emit("controlstoggle", new UniVideoControlsToggleEventImpl(JSON.parse<UniVideoControlsToggleEventDetail>(msg)!));
const detail = JSON.parse<UniVideoControlsToggleEventDetail>(msg)!;
if (detail.show && this.playerView.isFullscreen()) {
setTimeout(() => {
if (!this.playerView.isFocused()) this.playerView.requestFocus();
}, 100);
}
this.comp.$emit("controlstoggle", new UniVideoControlsToggleEventImpl(detail));
break;
case "error":
this.comp.$emit("error", new UniVideoErrorEventImpl(new VideoErrorImpl(100001)));
......@@ -762,8 +798,9 @@
this.playerView.pause();
this.playerView.setCenterPlayBntVisibility((this.comp as VideoComponent).showCenterPlayBtn);
(this.comp as VideoComponent).currentPos = this.playerView.getCurPosition();
(this.comp as VideoComponent).currentFrame?.recycle();
(this.comp as VideoComponent).currentFrame = this.playerView.captureFrame();
const frame = this.playerView.captureFrame();
(this.comp as VideoComponent).currentFrame = frame;
this.playerView.showLastFrame(frame);
}
}
}
......@@ -793,4 +830,26 @@
}
}
class OnKeyListenerImpl implements OnKeyListener {
private comp : UTSContainer<IjkPlayerView>;
private playerView : IjkPlayerView;
constructor(comp : UTSContainer<IjkPlayerView>) {
super();
this.comp = comp;
this.playerView = comp.$el!;
}
override onKey(v : View, keyCode : Int, event : KeyEvent) : Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
if (this.playerView.isFullscreen()) {
(this.comp as VideoComponent).exitFullScreen();
return true;
}
}
return false;
}
}
</script>
\ No newline at end of file
......@@ -8,32 +8,32 @@
<key>BinaryPath</key>
<string>DCUniVideo.framework/DCUniVideo</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>DCUniVideo.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>DCUniVideo.framework/DCUniVideo</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>DCUniVideo.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
......
#if 0
#elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// Generated by Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
#ifndef DCUNIVIDEO_SWIFT_H
#define DCUNIVIDEO_SWIFT_H
#pragma clang diagnostic push
......@@ -339,6 +339,15 @@ SWIFT_CLASS("_TtC10DCUniVideo13HJDanmakuView")
SWIFT_CLASS("_TtC10DCUniVideo23UniMonitoredContentView")
@interface UniMonitoredContentView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
- (void)didAddSubview:(UIView * _Nonnull)subview;
- (void)layoutSubviews;
@end
SWIFT_CLASS("_TtC10DCUniVideo20UniVideoPlayerConfig")
@interface UniVideoPlayerConfig : NSObject
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
......
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target arm64-apple-ios12.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name DCUniVideo
// swift-module-flags-ignorable: -enable-bare-slash-regex
// swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
// swift-module-flags: -target arm64-apple-ios12.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-bare-slash-regex -module-name DCUniVideo
import AVFAudio
import AVFoundation
import CommonCrypto
......@@ -58,6 +57,8 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func getCurrentUA() -> Swift.String
func sendEvent(_ name: Swift.String, _ params: [Swift.String : Any]?)
func loadImage(_ url: Swift.String, _ complete: @escaping (UIKit.UIImage) -> Swift.Void)
func videoPlayerWillEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerWillExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func lockScreen()
......@@ -71,6 +72,11 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func workRootPath() -> Swift.String
func videoCacheDir() -> Swift.String
}
@objc @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers @_Concurrency.MainActor(unsafe) public class UniMonitoredContentView : UIKit.UIView {
@_Concurrency.MainActor(unsafe) @objc override dynamic public func didAddSubview(_ subview: UIKit.UIView)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@objc deinit
}
final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
public typealias View = DCUniVideo.UniVideoPlayerView
final public var view: DCUniVideo.UniVideoPlayerViewPresent.View
......@@ -79,7 +85,7 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
get
set
}
final public var contentView: UIKit.UIView {
final public var contentView: DCUniVideo.UniMonitoredContentView {
get
set
}
......@@ -87,6 +93,9 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
@objc deinit
final public func updateViewFrame(_ rect: CoreFoundation.CGRect)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func onVideoComponentReused(_ config: DCUniVideo.UniVideoPlayerConfig)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func play()
final public func pause()
......
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target arm64-apple-ios12.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name DCUniVideo
// swift-module-flags-ignorable: -enable-bare-slash-regex
// swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
// swift-module-flags: -target arm64-apple-ios12.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-bare-slash-regex -module-name DCUniVideo
import AVFAudio
import AVFoundation
import CommonCrypto
......@@ -58,6 +57,8 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func getCurrentUA() -> Swift.String
func sendEvent(_ name: Swift.String, _ params: [Swift.String : Any]?)
func loadImage(_ url: Swift.String, _ complete: @escaping (UIKit.UIImage) -> Swift.Void)
func videoPlayerWillEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerWillExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func lockScreen()
......@@ -71,6 +72,11 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func workRootPath() -> Swift.String
func videoCacheDir() -> Swift.String
}
@objc @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers @_Concurrency.MainActor(unsafe) public class UniMonitoredContentView : UIKit.UIView {
@_Concurrency.MainActor(unsafe) @objc override dynamic public func didAddSubview(_ subview: UIKit.UIView)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@objc deinit
}
final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
public typealias View = DCUniVideo.UniVideoPlayerView
final public var view: DCUniVideo.UniVideoPlayerViewPresent.View
......@@ -79,7 +85,7 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
get
set
}
final public var contentView: UIKit.UIView {
final public var contentView: DCUniVideo.UniMonitoredContentView {
get
set
}
......@@ -87,6 +93,9 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
@objc deinit
final public func updateViewFrame(_ rect: CoreFoundation.CGRect)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func onVideoComponentReused(_ config: DCUniVideo.UniVideoPlayerConfig)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func play()
final public func pause()
......
#if 0
#elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// Generated by Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
#ifndef DCUNIVIDEO_SWIFT_H
#define DCUNIVIDEO_SWIFT_H
#pragma clang diagnostic push
......@@ -339,6 +339,15 @@ SWIFT_CLASS("_TtC10DCUniVideo13HJDanmakuView")
SWIFT_CLASS("_TtC10DCUniVideo23UniMonitoredContentView")
@interface UniMonitoredContentView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
- (void)didAddSubview:(UIView * _Nonnull)subview;
- (void)layoutSubviews;
@end
SWIFT_CLASS("_TtC10DCUniVideo20UniVideoPlayerConfig")
@interface UniVideoPlayerConfig : NSObject
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
......@@ -373,7 +382,7 @@ SWIFT_CLASS("_TtC10DCUniVideo18UniVideoPlayerView")
#endif
#elif defined(__x86_64__) && __x86_64__
// Generated by Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// Generated by Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
#ifndef DCUNIVIDEO_SWIFT_H
#define DCUNIVIDEO_SWIFT_H
#pragma clang diagnostic push
......@@ -712,6 +721,15 @@ SWIFT_CLASS("_TtC10DCUniVideo13HJDanmakuView")
SWIFT_CLASS("_TtC10DCUniVideo23UniMonitoredContentView")
@interface UniMonitoredContentView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame SWIFT_UNAVAILABLE;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
- (void)didAddSubview:(UIView * _Nonnull)subview;
- (void)layoutSubviews;
@end
SWIFT_CLASS("_TtC10DCUniVideo20UniVideoPlayerConfig")
@interface UniVideoPlayerConfig : NSObject
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
......
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target arm64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name DCUniVideo
// swift-module-flags-ignorable: -enable-bare-slash-regex
// swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
// swift-module-flags: -target arm64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-bare-slash-regex -module-name DCUniVideo
import AVFAudio
import AVFoundation
import CommonCrypto
......@@ -58,6 +57,8 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func getCurrentUA() -> Swift.String
func sendEvent(_ name: Swift.String, _ params: [Swift.String : Any]?)
func loadImage(_ url: Swift.String, _ complete: @escaping (UIKit.UIImage) -> Swift.Void)
func videoPlayerWillEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerWillExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func lockScreen()
......@@ -71,6 +72,11 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func workRootPath() -> Swift.String
func videoCacheDir() -> Swift.String
}
@objc @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers @_Concurrency.MainActor(unsafe) public class UniMonitoredContentView : UIKit.UIView {
@_Concurrency.MainActor(unsafe) @objc override dynamic public func didAddSubview(_ subview: UIKit.UIView)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@objc deinit
}
final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
public typealias View = DCUniVideo.UniVideoPlayerView
final public var view: DCUniVideo.UniVideoPlayerViewPresent.View
......@@ -79,7 +85,7 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
get
set
}
final public var contentView: UIKit.UIView {
final public var contentView: DCUniVideo.UniMonitoredContentView {
get
set
}
......@@ -87,6 +93,9 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
@objc deinit
final public func updateViewFrame(_ rect: CoreFoundation.CGRect)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func onVideoComponentReused(_ config: DCUniVideo.UniVideoPlayerConfig)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func play()
final public func pause()
......
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target arm64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name DCUniVideo
// swift-module-flags-ignorable: -enable-bare-slash-regex
// swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
// swift-module-flags: -target arm64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-bare-slash-regex -module-name DCUniVideo
import AVFAudio
import AVFoundation
import CommonCrypto
......@@ -58,6 +57,8 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func getCurrentUA() -> Swift.String
func sendEvent(_ name: Swift.String, _ params: [Swift.String : Any]?)
func loadImage(_ url: Swift.String, _ complete: @escaping (UIKit.UIImage) -> Swift.Void)
func videoPlayerWillEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerWillExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func lockScreen()
......@@ -71,6 +72,11 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func workRootPath() -> Swift.String
func videoCacheDir() -> Swift.String
}
@objc @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers @_Concurrency.MainActor(unsafe) public class UniMonitoredContentView : UIKit.UIView {
@_Concurrency.MainActor(unsafe) @objc override dynamic public func didAddSubview(_ subview: UIKit.UIView)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@objc deinit
}
final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
public typealias View = DCUniVideo.UniVideoPlayerView
final public var view: DCUniVideo.UniVideoPlayerViewPresent.View
......@@ -79,7 +85,7 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
get
set
}
final public var contentView: UIKit.UIView {
final public var contentView: DCUniVideo.UniMonitoredContentView {
get
set
}
......@@ -87,6 +93,9 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
@objc deinit
final public func updateViewFrame(_ rect: CoreFoundation.CGRect)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func onVideoComponentReused(_ config: DCUniVideo.UniVideoPlayerConfig)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func play()
final public func pause()
......
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target x86_64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name DCUniVideo
// swift-module-flags-ignorable: -enable-bare-slash-regex
// swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
// swift-module-flags: -target x86_64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-bare-slash-regex -module-name DCUniVideo
import AVFAudio
import AVFoundation
import CommonCrypto
......@@ -58,6 +57,8 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func getCurrentUA() -> Swift.String
func sendEvent(_ name: Swift.String, _ params: [Swift.String : Any]?)
func loadImage(_ url: Swift.String, _ complete: @escaping (UIKit.UIImage) -> Swift.Void)
func videoPlayerWillEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerWillExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func lockScreen()
......@@ -71,6 +72,11 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func workRootPath() -> Swift.String
func videoCacheDir() -> Swift.String
}
@objc @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers @_Concurrency.MainActor(unsafe) public class UniMonitoredContentView : UIKit.UIView {
@_Concurrency.MainActor(unsafe) @objc override dynamic public func didAddSubview(_ subview: UIKit.UIView)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@objc deinit
}
final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
public typealias View = DCUniVideo.UniVideoPlayerView
final public var view: DCUniVideo.UniVideoPlayerViewPresent.View
......@@ -79,7 +85,7 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
get
set
}
final public var contentView: UIKit.UIView {
final public var contentView: DCUniVideo.UniMonitoredContentView {
get
set
}
......@@ -87,6 +93,9 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
@objc deinit
final public func updateViewFrame(_ rect: CoreFoundation.CGRect)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func onVideoComponentReused(_ config: DCUniVideo.UniVideoPlayerConfig)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func play()
final public func pause()
......
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target x86_64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name DCUniVideo
// swift-module-flags-ignorable: -enable-bare-slash-regex
// swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
// swift-module-flags: -target x86_64-apple-ios12.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-bare-slash-regex -module-name DCUniVideo
import AVFAudio
import AVFoundation
import CommonCrypto
......@@ -58,6 +57,8 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func getCurrentUA() -> Swift.String
func sendEvent(_ name: Swift.String, _ params: [Swift.String : Any]?)
func loadImage(_ url: Swift.String, _ complete: @escaping (UIKit.UIImage) -> Swift.Void)
func videoPlayerWillEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerWillExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerExitFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func videoPlayerEnterFullScreen(_ orientation: UIKit.UIInterfaceOrientation)
func lockScreen()
......@@ -71,6 +72,11 @@ public protocol UniVideoPlayerProtocol : AnyObject {
func workRootPath() -> Swift.String
func videoCacheDir() -> Swift.String
}
@objc @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers @_Concurrency.MainActor(unsafe) public class UniMonitoredContentView : UIKit.UIView {
@_Concurrency.MainActor(unsafe) @objc override dynamic public func didAddSubview(_ subview: UIKit.UIView)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@objc deinit
}
final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
public typealias View = DCUniVideo.UniVideoPlayerView
final public var view: DCUniVideo.UniVideoPlayerViewPresent.View
......@@ -79,7 +85,7 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
get
set
}
final public var contentView: UIKit.UIView {
final public var contentView: DCUniVideo.UniMonitoredContentView {
get
set
}
......@@ -87,6 +93,9 @@ final public class UniVideoPlayerViewPresent : DCUniVideo.ViewPresent {
@objc deinit
final public func updateViewFrame(_ rect: CoreFoundation.CGRect)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func onVideoComponentReused(_ config: DCUniVideo.UniVideoPlayerConfig)
}
extension DCUniVideo.UniVideoPlayerViewPresent {
final public func play()
final public func pause()
......
......@@ -6,7 +6,7 @@
<dict>
<key>Headers/DCUniVideo-Swift.h</key>
<data>
8RtESNpNJ/MLh4AISu16ekCnNgM=
6AI8KDmmckpzHIE9MTA87TBlOEA=
</data>
<key>Headers/DCUniVideo.h</key>
<data>
......@@ -18,55 +18,55 @@
</data>
<key>Info.plist</key>
<data>
ZJfU/z0myJ2FJ6v4FI5s1po6+18=
4STIX+M3zL3GrGrwOIBZ35QNXpQ=
</data>
<key>Modules/DCUniVideo.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo</key>
<data>
LMw61NwrRpA08JKfgcEYaj3bC4s=
/CTSTQuMxlC70vyU7iOX8wGDf+4=
</data>
<key>Modules/DCUniVideo.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
<data>
7RwLqhAfiKvxA+Cxv6/N962PpOg=
64wiXw8pS4gsJb8AmmNjU/dce+M=
</data>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
<data>
nk9o0CXiQ/GZWFtpqNFQSf56Aq4=
6g7piUV4/cufnba98Op8+kJw65E=
</data>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
<data>
TYzZQAPhXzOjxQ7cOKZu2E3/gOM=
AT+Uc934hqQ5s7XiudgE4R+Klag=
</data>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
<data>
zaMs+qbaViQJV9jdtXLqo29LabM=
skvNhIA0R3GI+di1j0sdu/54Jgo=
</data>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
<data>
TYzZQAPhXzOjxQ7cOKZu2E3/gOM=
AT+Uc934hqQ5s7XiudgE4R+Klag=
</data>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
<data>
gR2m/jlpxNCVmIfuV+qVvd6FVoE=
4WOy1OqT/1CovEL8hNH7mPVwr/U=
</data>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
<data>
nk9o0CXiQ/GZWFtpqNFQSf56Aq4=
6g7piUV4/cufnba98Op8+kJw65E=
</data>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
<data>
P9A/XUTYbV9hqAFkvIsnL90B8HQ=
9EbVYjfn5tKvGE1pRend6D42C7g=
</data>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
<data>
tMymyR7BzfUWQ9cTfV/3r+zajeY=
WeMQjnMJwgj3QZJ6JvPtSkLHDfw=
</data>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
<data>
P9A/XUTYbV9hqAFkvIsnL90B8HQ=
9EbVYjfn5tKvGE1pRend6D42C7g=
</data>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
<data>
p+SyNnDNf1lc0DyiX5aiSin5puk=
868ltQGQ9ZGE5Iyk1H7oWXmN8JY=
</data>
<key>Modules/module.modulemap</key>
<data>
......@@ -79,11 +79,11 @@
<dict>
<key>hash</key>
<data>
8RtESNpNJ/MLh4AISu16ekCnNgM=
6AI8KDmmckpzHIE9MTA87TBlOEA=
</data>
<key>hash2</key>
<data>
6rkDl2fzm2saIt4Lj2MYeOP5Z1dDjaCYAEu7PhIdI/k=
N818DwGCZblozLzhJGHxkM9CUzR3/hgBV+b2dliE1bk=
</data>
</dict>
<key>Headers/DCUniVideo.h</key>
......@@ -112,132 +112,132 @@
<dict>
<key>hash</key>
<data>
LMw61NwrRpA08JKfgcEYaj3bC4s=
/CTSTQuMxlC70vyU7iOX8wGDf+4=
</data>
<key>hash2</key>
<data>
rQ6ecTyNYorIWSPYIIIvMKXzPCj9nGj+LNKMEIJBP5U=
mXFCGPbsKJ1JiOP54zWfFztb2vrPw+3oQonSw3l6RUc=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
<dict>
<key>hash</key>
<data>
7RwLqhAfiKvxA+Cxv6/N962PpOg=
64wiXw8pS4gsJb8AmmNjU/dce+M=
</data>
<key>hash2</key>
<data>
Un6dHCBddlRbwPe/xkfXUJUkqJfmlwC9uhfZwcpAHos=
BLjUlDgXs4UIoOKdAhIC+N1JYbZpgOOlezMlmxeFbO4=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
<dict>
<key>hash</key>
<data>
nk9o0CXiQ/GZWFtpqNFQSf56Aq4=
6g7piUV4/cufnba98Op8+kJw65E=
</data>
<key>hash2</key>
<data>
G6BCmgVzUh+8PT4Vb2Mo2M57OK54006L7d81dNPspfY=
JQ/uRwcNEZAemsl2XxnN+U1LH2g5HWw9hODc1t6xrSk=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
<dict>
<key>hash</key>
<data>
TYzZQAPhXzOjxQ7cOKZu2E3/gOM=
AT+Uc934hqQ5s7XiudgE4R+Klag=
</data>
<key>hash2</key>
<data>
fGUfQRyQkDydTP0YQ2ycZuJ+xLOTauxL6nBJJtVHeUo=
OcfDfHnBnZ1Cc8+ED7WInmje9+thSxUDvdHE7HK2UdQ=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
<dict>
<key>hash</key>
<data>
zaMs+qbaViQJV9jdtXLqo29LabM=
skvNhIA0R3GI+di1j0sdu/54Jgo=
</data>
<key>hash2</key>
<data>
ltXhZrQmuZPwZ/zatuXP0+KdjKP8anH8ihgjTcDuFzc=
lNWH1MV4Mzre1nP4Za3ZX5YObDq5i/XHbsm1fIREytI=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
<dict>
<key>hash</key>
<data>
TYzZQAPhXzOjxQ7cOKZu2E3/gOM=
AT+Uc934hqQ5s7XiudgE4R+Klag=
</data>
<key>hash2</key>
<data>
fGUfQRyQkDydTP0YQ2ycZuJ+xLOTauxL6nBJJtVHeUo=
OcfDfHnBnZ1Cc8+ED7WInmje9+thSxUDvdHE7HK2UdQ=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
<dict>
<key>hash</key>
<data>
gR2m/jlpxNCVmIfuV+qVvd6FVoE=
4WOy1OqT/1CovEL8hNH7mPVwr/U=
</data>
<key>hash2</key>
<data>
kSBWEAVrVxWfOnEsU4ryWR+gx8eY6RmX8ppIpJlBx9A=
z+56Py2JAl94oNNpRG54OpTOYx6MytxbwujY5jTFiwc=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
<dict>
<key>hash</key>
<data>
nk9o0CXiQ/GZWFtpqNFQSf56Aq4=
6g7piUV4/cufnba98Op8+kJw65E=
</data>
<key>hash2</key>
<data>
G6BCmgVzUh+8PT4Vb2Mo2M57OK54006L7d81dNPspfY=
JQ/uRwcNEZAemsl2XxnN+U1LH2g5HWw9hODc1t6xrSk=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
<dict>
<key>hash</key>
<data>
P9A/XUTYbV9hqAFkvIsnL90B8HQ=
9EbVYjfn5tKvGE1pRend6D42C7g=
</data>
<key>hash2</key>
<data>
VzdCbPQNtj1hylfhs2PD3X4eBPdh0GAfIBhp+KSR+P4=
ElH2U0ZxMym5pgUUeycsjfZ8NlPNEW7dLNFHVhUIRUk=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
<dict>
<key>hash</key>
<data>
tMymyR7BzfUWQ9cTfV/3r+zajeY=
WeMQjnMJwgj3QZJ6JvPtSkLHDfw=
</data>
<key>hash2</key>
<data>
9dLnwDexyVteRT+z/YK1LMyqtXXzArso9N35QjFp6bU=
nqCcouRnuFnUpuLy2+rb6C6BrrEytmIDxcf70dIRpyU=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
<dict>
<key>hash</key>
<data>
P9A/XUTYbV9hqAFkvIsnL90B8HQ=
9EbVYjfn5tKvGE1pRend6D42C7g=
</data>
<key>hash2</key>
<data>
VzdCbPQNtj1hylfhs2PD3X4eBPdh0GAfIBhp+KSR+P4=
ElH2U0ZxMym5pgUUeycsjfZ8NlPNEW7dLNFHVhUIRUk=
</data>
</dict>
<key>Modules/DCUniVideo.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
<dict>
<key>hash</key>
<data>
p+SyNnDNf1lc0DyiX5aiSin5puk=
868ltQGQ9ZGE5Iyk1H7oWXmN8JY=
</data>
<key>hash2</key>
<data>
AYg5nbZM23N1eAD0JL/9x+MWHN0Lplo1fiDhPwHVPtc=
QwlZD6edjFe9YD6Q6lQL7b23TVaPh7+GWMOLiEahBsc=
</data>
</dict>
<key>Modules/module.modulemap</key>
......
<template>
<view style="width: 300px;height: 225px;">
<slot />
</view>
</template>
<script lang="uts">
import { UniVideoPlayerConfig, UniVideoPlayerViewPresent } from "DCUniVideo" assert { type: "implementationOnly" };
import { URL, NSDictionary, CGFloat } from "Foundation";
import { UIImage, UIInterfaceOrientationMask, UIInterfaceOrientation, UIView } from 'UIKit';
import { Bool, Int } from 'Swift';
import { Danmu } from "../interface.uts"
export default {
name: "video",
data() {
return {
present: null as UniVideoPlayerViewPresent | null,
delegate: null as DCloudUniVideoComponentDelegate | null,
};
},
emits: ["play", "pause", "ended", "timeupdate", "fullscreenchange", "waiting", "error", "progress", "fullscreenclick", "controlstoggle"],
props: {
"src": { // 要播放视频的资源地址
type: String,
default: ""
},
"autoplay": { // 是否自动播放
type: Boolean,
default: false
},
"loop": { // 是否循环播放
type: Boolean,
default: false
},
"muted": { // 是否静音播放
type: Boolean,
default: false
},
"initialTime": { // 指定视频初始播放位置,单位为秒(s)
type: Number,
default: 0
},
"duration": { // 指定视频时长,单位为秒(s)
type: Number,
default: 0
},
"controls": { // 是否显示默认播放控件(播放/暂停按钮、播放进度、时间)
type: Boolean,
default: true
},
"danmuList": { // 弹幕列表
type: Array as NSDictionary[],
default: []
},
"danmuBtn": { // 是否显示弹幕按钮,只在初始化时有效,不能动态变更
type: Boolean,
default: false
},
"enableDanmu": { // 是否展示弹幕,只在初始化时有效,不能动态变更
type: Boolean,
default: false
},
"pageGesture": { // 在非全屏模式下,是否开启亮度与音量调节手势
type: Boolean,
default: false
},
"direction": { // 设置全屏时视频的方向,不指定则根据宽高比自动判断。有效值为 0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)
type: Number,
default: -90
},
"showProgress": { // 是否展示进度条,若不设置,宽度大于240时才会显示
type: Boolean,
default: true
},
"showFullscreenBtn": { // 是否显示全屏按钮
type: Boolean,
default: true
},
"showPlayBtn": { // 是否显示视频底部控制栏的播放按钮
type: Boolean,
default: true
},
"showCenterPlayBtn": { // 是否显示视频中间的播放按钮
type: Boolean,
default: true
},
"showLoading": { // 是否显示loading控件
type: Boolean,
default: true
},
"enableProgressGesture": { // 是否开启控制进度的手势
type: Boolean,
default: true
},
"objectFit": { // 当视频大小与 video 容器大小不一致时,视频的表现形式。contain:包含,fill:填充,cover:覆盖
type: String,
default: "contain"
},
"poster": { // 视频封面的图片网络资源地址,如果 controls 属性值为 false 则设置 poster 无效
type: String,
default: ""
},
"showMuteBtn": { // 是否显示静音按钮
type: Boolean,
default: false
},
"title": { // 视频的标题,全屏时在顶部展示
type: String,
default: ""
},
"enablePlayGesture": { // 是否开启播放手势,即双击切换播放/暂停
type: Boolean,
default: false
},
"vslideGesture": { // 在非全屏模式下,是否开启亮度与音量调节手势(同 page-gesture)
type: Boolean,
default: false
},
"vslideGestureInFullscreen": { // 在全屏模式下,是否开启亮度与音量调节手势
type: Boolean,
default: true
},
"codec": { // 解码器选择,hardware:硬解码(硬解码可以增加解码算力,提高视频清晰度。少部分老旧硬件可能存在兼容性问题);software:ffmpeg 软解码;
type: String,
default: "hardware"
},
"httpCache": { // 是否对 http、https 视频源开启本地缓存。缓存策略:开启了此开关的视频源,在视频播放时会在本地保存缓存文件,如果本地缓存池已超过100M,在进行缓存前会清空之前的缓存(不适用于m3u8等流媒体协议)
type: Boolean,
default: false
},
"playStrategy": { // 播放策略,0:普通模式,适合绝大部分视频播放场景;1:平滑播放模式(降级),增加缓冲区大小,采用open sl解码音频,避免音视频脱轨的问题,可能会降低首屏展现速度、视频帧率,出现开屏音频延迟等。 适用于高码率视频的极端场景;2: M3U8优化模式,增加缓冲区大小,提升视频加载速度和流畅度,可能会降低首屏展现速度。 适用于M3U8在线播放的场景
type: Number,
default: 0
},
"header": { // HTTP 请求 Header
type: Map<string, string>,
default: new Map<string, string>()
},
},
watch: {
"src": {
handler(newValue : String, oldValue : String) {
"[weak self]"
this?.updateProp("src", newValue);
},
immediate: false
},
"autoplay": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("autoplay", newValue);
},
immediate: false
},
"loop": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("loop", newValue);
},
immediate: false
},
"muted": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("muted", newValue);
},
immediate: false
},
"initialTime": {
handler(newValue: Number, oldValue: Number) {
"[weak self]"
this?.updateProp("initialTime", newValue);
},
immediate: false
},
"duration": {
handler(newValue: Number, oldValue: Number) {
"[weak self]"
this?.updateProp("duration", newValue);
},
immediate: false
},
"controls": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("controls", newValue);
},
immediate: false
},
"danmuList": {
handler(newValue : NSDictionary[], oldValue : NSDictionary[]) {
"[weak self]"
this?.updateProp("danmuList", newValue);
},
immediate: false
},
"danmuBtn": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("danmuBtn", newValue);
},
immediate: false
},
"enableDanmu": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("enableDanmu", newValue);
},
immediate: false
},
"pageGesture": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("pageGesture", newValue);
},
immediate: false
},
"direction": {
handler(newValue: Number, oldValue: Number) {
"[weak self]"
this?.updateProp("direction", newValue);
},
immediate: false
},
"showProgress": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("showProgress", newValue);
},
immediate: false
},
"showFullscreenBtn": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("showFullscreenBtn", newValue);
},
immediate: false
},
"showPlayBtn": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("showPlayBtn", newValue);
},
immediate: false
},
"showCenterPlayBtn": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("showCenterPlayBtn", newValue);
},
immediate: false
},
"showLoading": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("showLoading", newValue);
},
immediate: false
},
"enableProgressGesture": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("enableProgressGesture", newValue);
},
immediate: false
},
"objectFit": {
handler(newValue: String, oldValue: String) {
"[weak self]"
this?.updateProp("objectFit", newValue);
},
immediate: false
},
"poster": {
handler(newValue: String, oldValue: String) {
"[weak self]"
this?.updateProp("poster", newValue);
},
immediate: false
},
"showMuteBtn": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("showMuteBtn", newValue);
},
immediate: false
},
"title": {
handler(newValue: String, oldValue: String) {
"[weak self]"
this?.updateProp("title", newValue);
},
immediate: false
},
"enablePlayGesture": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("enablePlayGesture", newValue);
},
immediate: false
},
"vslideGesture": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("vslideGesture", newValue);
},
immediate: false
},
"vslideGestureInFullscreen": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("vslideGestureInFullscreen", newValue);
},
immediate: false
},
"httpCache": {
handler(newValue: Boolean, oldValue: Boolean) {
"[weak self]"
this?.updateProp("httpCache", newValue);
},
immediate: false
},
"codec": {
handler(newValue: string, oldValue: string) {
"[weak self]"
this?.updateProp("codec", newValue);
},
immediate: false
},
"playStrategy": {
handler(newValue: number, oldValue: number) {
"[weak self]"
this?.updateProp("playStrategy", newValue);
},
immediate: false
},
"header": {
handler(newValue : Map<string, any>, oldValue : Map<string, any>) {
"[weak self]"
let newStr = JSON.stringify(newValue)
let oldStr = JSON.stringify(oldValue)
if (newStr != oldStr) {
this?.updateProp("header", newValue);
}
},
immediate: false
}
},
created() {
let config = UniVideoPlayerConfig.init(options = this.attributes)
this.delegate = new DCloudUniVideoComponentDelegate(this)
this.present = new UniVideoPlayerViewPresent.init(config, this.delegate)
if (this.delegate != null) {
this.present!.delegate = this.delegate
}
},
NVLoad() : UIView {
if (this.present != null) {
return this.present!.contentView;
} else{
return new UIView()
}
},
NVLayouted() {
if (!UTSiOS.isScreenLocked()) {
this.present?.updateViewFrame(this.calculatedFrame);
}
},
unmounted() { //释放播放器
this.present?.destroy();
},
expose: ['play', 'pause', 'seek', 'stop', 'sendDanmu', 'playbackRate', 'requestFullScreen', 'exitFullScreen', 'showStatusBar', 'hideStatusBar'],
methods: {
/**
* 播放视频
*/
play: function () {
this.present?.play()
},
/**
* 暂停视频
*/
pause: function () {
this.present?.pause()
},
/**
* 跳转到指定位置
* @param pos 跳转到的位置,单位:秒(s)
*/
seek: function (pos : number) {
this.present?.seek(pos.floatValue)
},
/**
* 切换到全屏
* @param direction 视频方向,0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)
*/
requestFullScreen: function (direction : number) {
let dir = UniVideoPlayerConfig.direction(direction)
this.present?.requestFullScreen(dir)
},
/**
* 退出全屏
*/
exitFullScreen: function () {
this.present?.exitFullScreenForJS()
},
/**
* 停止播放视频
*/
stop: function () {
this.present?.stop()
},
/** 
* 显示状态栏,仅在iOS全屏下有效
*/
showStatusBar: function () {
this.present?.showStatusBar()
},
/**
* 隐藏状态栏,仅在iOS全屏下有效
*/
hideStatusBar: function () {
this.present?.hideStatusBar()
},
/**
* 发送弹幕
* @param data 弹幕数据
*/
sendDanmu: function (data : Map<string, any>) {
this.present?.sendDanmu(data)
},
/**
* 设置倍速播放
* @param rate 播放的倍率
*/
playbackRate: function (rate : string) {
this.present?.palybackRate(rate);
},
updateProp: function (key: string, value: any | null) {
DispatchQueue.main.async(execute=():void => {
this.present?.setControlValue(value, key)
})
}
}
}
@UTSiOS.keyword("private")
class DCloudUniVideoComponentDelegate implements UniVideoPlayerProtocol {
@UTSiOS.keyword("weak")
private component: VideoComponent | null = null
constructor(component: VideoComponent) {
this.component = component
super.init()
}
getCookieString(url: URL): string | null {
return UTSiOS.getCookieString(url)
}
getCurrentUA(): string {
return UTSiOS.getUserAgent()
}
sendEvent(name: string, params: Dictionary<string,any> | null) {
switch (name){
case "play":
case "pause":
case "waiting":
case "ended":
case "error":
case "click":
this.component?.__$$emit(name);
break;
case "timeupdate":
case "fullscreenclick":
case "fullscreenchange":
case "controlstoggle":
this.component?.__$$emit(name, params);
break;
default:
break;
}
}
loadImage(url: string, complete: (image: UIImage) => void) {
UTSiOS.loadImage(url,(image,data) => {
if(image != null){
complete(image!);
}
});
}
lockScreen() {
UTSiOS.lockScreen()
}
unlockScreen() {
UTSiOS.unlockScreen()
}
setFullScreen(yesOrNo: boolean) {
UTSiOS.setFullScreen(yesOrNo)
}
setHomeIndicatorAutoHidden(yesOrNo: boolean) {
UTSiOS.setHomeIndicatorAutoHidden(yesOrNo)
}
setTempOrientation(temp: UIInterfaceOrientationMask) {
UTSiOS.setTempOrientation(temp)
}
configSupportOrientation(orientation: UIInterfaceOrientation): boolean {
return UTSiOS.configSupportOrientation(orientation)
}
setDeviceInterfaceOrientation(orientation: UIInterfaceOrientation) {
UTSiOS.setDeviceInterfaceOrientation(orientation)
}
h5Path2SysPath(path: string, basePath: string | null) : string {
return UTSiOS.getResourceAbsolutePath(path, basePath)
}
workRootPath() : string {
return UTSiOS.getWorkRootPath()
}
videoPlayerExitFullScreen(orientation: UIInterfaceOrientation) {
}
videoPlayerEnterFullScreen(orientation: UIInterfaceOrientation) {
}
videoCacheDir(): string {
return UTSiOS.getVideoCacheDir()
}
}
<template>
<view style="width: 300px;height: 225px;">
<slot />
</view>
</template>
<script lang="uts">
import { UniVideoPlayerConfig, UniVideoPlayerViewPresent } from "DCUniVideo" assert { type: "implementationOnly" };
import { URL, NSDictionary, CGFloat } from "Foundation";
import { UIImage, UIInterfaceOrientationMask, UIInterfaceOrientation, UIView, UIScreen, CGRect } from 'UIKit';
import { Bool, Int } from 'Swift';
import { Danmu } from "../interface.uts";
import { UniCssFlexEdge } from "DCloudUniappRuntime";
export default {
name: "video",
data() {
return {
present: null as UniVideoPlayerViewPresent | null,
delegate: null as DCloudUniVideoComponentDelegate | null,
};
},
emits: ["play", "pause", "ended", "timeupdate", "fullscreenchange", "waiting", "error", "progress", "fullscreenclick", "controlstoggle"],
props: {
"src": { // 要播放视频的资源地址
type: String,
default: ""
},
"autoplay": { // 是否自动播放
type: Boolean,
default: false
},
"loop": { // 是否循环播放
type: Boolean,
default: false
},
"muted": { // 是否静音播放
type: Boolean,
default: false
},
"initialTime": { // 指定视频初始播放位置,单位为秒(s)
type: Number,
default: 0
},
"duration": { // 指定视频时长,单位为秒(s)
type: Number,
default: 0
},
"controls": { // 是否显示默认播放控件(播放/暂停按钮、播放进度、时间)
type: Boolean,
default: true
},
"danmuList": { // 弹幕列表
type: Array as NSDictionary[],
default: []
},
"danmuBtn": { // 是否显示弹幕按钮,只在初始化时有效,不能动态变更
type: Boolean,
default: false
},
"enableDanmu": { // 是否展示弹幕,只在初始化时有效,不能动态变更
type: Boolean,
default: false
},
"pageGesture": { // 在非全屏模式下,是否开启亮度与音量调节手势
type: Boolean,
default: false
},
"direction": { // 设置全屏时视频的方向,不指定则根据宽高比自动判断。有效值为 0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)
type: Number,
default: -90
},
"showProgress": { // 是否展示进度条,若不设置,宽度大于240时才会显示
type: Boolean,
default: true
},
"showFullscreenBtn": { // 是否显示全屏按钮
type: Boolean,
default: true
},
"showPlayBtn": { // 是否显示视频底部控制栏的播放按钮
type: Boolean,
default: true
},
"showCenterPlayBtn": { // 是否显示视频中间的播放按钮
type: Boolean,
default: true
},
"showLoading": { // 是否显示loading控件
type: Boolean,
default: true
},
"enableProgressGesture": { // 是否开启控制进度的手势
type: Boolean,
default: true
},
"objectFit": { // 当视频大小与 video 容器大小不一致时,视频的表现形式。contain:包含,fill:填充,cover:覆盖
type: String,
default: "contain"
},
"poster": { // 视频封面的图片网络资源地址,如果 controls 属性值为 false 则设置 poster 无效
type: String,
default: ""
},
"showMuteBtn": { // 是否显示静音按钮
type: Boolean,
default: false
},
"title": { // 视频的标题,全屏时在顶部展示
type: String,
default: ""
},
"enablePlayGesture": { // 是否开启播放手势,即双击切换播放/暂停
type: Boolean,
default: false
},
"vslideGesture": { // 在非全屏模式下,是否开启亮度与音量调节手势(同 page-gesture)
type: Boolean,
default: false
},
"vslideGestureInFullscreen": { // 在全屏模式下,是否开启亮度与音量调节手势
type: Boolean,
default: true
},
"codec": { // 解码器选择,hardware:硬解码(硬解码可以增加解码算力,提高视频清晰度。少部分老旧硬件可能存在兼容性问题);software:ffmpeg 软解码;
type: String,
default: "hardware"
},
"httpCache": { // 是否对 http、https 视频源开启本地缓存。缓存策略:开启了此开关的视频源,在视频播放时会在本地保存缓存文件,如果本地缓存池已超过100M,在进行缓存前会清空之前的缓存(不适用于m3u8等流媒体协议)
type: Boolean,
default: false
},
"playStrategy": { // 播放策略,0:普通模式,适合绝大部分视频播放场景;1:平滑播放模式(降级),增加缓冲区大小,采用open sl解码音频,避免音视频脱轨的问题,可能会降低首屏展现速度、视频帧率,出现开屏音频延迟等。 适用于高码率视频的极端场景;2: M3U8优化模式,增加缓冲区大小,提升视频加载速度和流畅度,可能会降低首屏展现速度。 适用于M3U8在线播放的场景
type: Number,
default: 0
},
"header": { // HTTP 请求 Header
type: Map<string, string>,
default: new Map<string, string>()
},
},
watch: {
"src": {
handler(newValue : String, oldValue : String) {
"[weak self]"
this?.updateProp("src", newValue);
},
immediate: false
},
"autoplay": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("autoplay", newValue);
},
immediate: false
},
"loop": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("loop", newValue);
},
immediate: false
},
"muted": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("muted", newValue);
},
immediate: false
},
"initialTime": {
handler(newValue : Number, oldValue : Number) {
"[weak self]"
this?.updateProp("initialTime", newValue);
},
immediate: false
},
"duration": {
handler(newValue : Number, oldValue : Number) {
"[weak self]"
this?.updateProp("duration", newValue);
},
immediate: false
},
"controls": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("controls", newValue);
},
immediate: false
},
"danmuList": {
handler(newValue : NSDictionary[], oldValue : NSDictionary[]) {
"[weak self]"
this?.updateProp("danmuList", newValue);
},
immediate: false
},
"danmuBtn": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("danmuBtn", newValue);
},
immediate: false
},
"enableDanmu": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("enableDanmu", newValue);
},
immediate: false
},
"pageGesture": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("pageGesture", newValue);
},
immediate: false
},
"direction": {
handler(newValue : Number, oldValue : Number) {
"[weak self]"
this?.updateProp("direction", newValue);
},
immediate: false
},
"showProgress": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("showProgress", newValue);
},
immediate: false
},
"showFullscreenBtn": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("showFullscreenBtn", newValue);
},
immediate: false
},
"showPlayBtn": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("showPlayBtn", newValue);
},
immediate: false
},
"showCenterPlayBtn": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("showCenterPlayBtn", newValue);
},
immediate: false
},
"showLoading": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("showLoading", newValue);
},
immediate: false
},
"enableProgressGesture": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("enableProgressGesture", newValue);
},
immediate: false
},
"objectFit": {
handler(newValue : String, oldValue : String) {
"[weak self]"
this?.updateProp("objectFit", newValue);
},
immediate: false
},
"poster": {
handler(newValue : String, oldValue : String) {
"[weak self]"
this?.updateProp("poster", newValue);
},
immediate: false
},
"showMuteBtn": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("showMuteBtn", newValue);
},
immediate: false
},
"title": {
handler(newValue : String, oldValue : String) {
"[weak self]"
this?.updateProp("title", newValue);
},
immediate: false
},
"enablePlayGesture": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("enablePlayGesture", newValue);
},
immediate: false
},
"vslideGesture": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("vslideGesture", newValue);
},
immediate: false
},
"vslideGestureInFullscreen": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("vslideGestureInFullscreen", newValue);
},
immediate: false
},
"httpCache": {
handler(newValue : Boolean, oldValue : Boolean) {
"[weak self]"
this?.updateProp("httpCache", newValue);
},
immediate: false
},
"codec": {
handler(newValue : string, oldValue : string) {
"[weak self]"
this?.updateProp("codec", newValue);
},
immediate: false
},
"playStrategy": {
handler(newValue : number, oldValue : number) {
"[weak self]"
this?.updateProp("playStrategy", newValue);
},
immediate: false
},
"header": {
handler(newValue : Map<string, any>, oldValue : Map<string, any>) {
"[weak self]"
let newStr = JSON.stringify(newValue)
let oldStr = JSON.stringify(oldValue)
if (newStr != oldStr) {
this?.updateProp("header", newValue);
}
},
immediate: false
}
},
created() {
let config = UniVideoPlayerConfig.init(options = this.attributes)
this.delegate = new DCloudUniVideoComponentDelegate(this)
this.present = new UniVideoPlayerViewPresent.init(config, this.delegate)
if (this.delegate != null) {
this.present!.delegate = this.delegate
}
},
NVLoad() : UIView {
if (this.present != null) {
return this.present!.contentView;
} else {
return new UIView()
}
},
NVLayouted() {
if (!UTSiOS.isScreenLocked()) {
this.present?.updateViewFrame(this.calculatedFrame);
}
},
unmounted() { //释放播放器
this.present?.destroy();
},
expose: ['play', 'pause', 'seek', 'stop', 'sendDanmu', 'playbackRate', 'requestFullScreen', 'exitFullScreen', 'showStatusBar', 'hideStatusBar'],
methods: {
/**
* 播放视频
*/
play: function () {
this.present?.play()
},
/**
* 暂停视频
*/
pause: function () {
this.present?.pause()
},
/**
* 跳转到指定位置
* @param pos 跳转到的位置,单位:秒(s)
*/
seek: function (pos : number) {
this.present?.seek(pos.floatValue)
},
/**
* 切换到全屏
* @param direction 视频方向,0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)
*/
requestFullScreen: function (direction : number) {
let dir = UniVideoPlayerConfig.direction(direction)
this.present?.requestFullScreen(dir)
},
/**
* 退出全屏
*/
exitFullScreen: function () {
this.present?.exitFullScreenForJS()
},
/**
* 停止播放视频
*/
stop: function () {
this.present?.stop()
},
/**
* 显示状态栏,仅在iOS全屏下有效
*/
showStatusBar: function () {
this.present?.showStatusBar()
},
/**
* 隐藏状态栏,仅在iOS全屏下有效
*/
hideStatusBar: function () {
this.present?.hideStatusBar()
},
/**
* 发送弹幕
* @param data 弹幕数据
*/
sendDanmu: function (data : Map<string, any>) {
this.present?.sendDanmu(data)
},
/**
* 设置倍速播放
* @param rate 播放的倍率
*/
playbackRate: function (rate : string) {
this.present?.palybackRate(rate);
},
updateProp: function (key : string, value : any | null) {
DispatchQueue.main.async(execute = () : void => {
this.present?.setControlValue(value, key)
})
}
}
}
@UTSiOS.keyword("private")
class DCloudUniVideoComponentDelegate implements UniVideoPlayerProtocol {
@UTSiOS.keyword("weak")
private component : VideoComponent | null = null
private originalFrame : CGRect | null = null
//todotest
constructor(component : VideoComponent) {
this.component = component
super.init()
}
getCookieString(url : URL) : string | null {
return UTSiOS.getCookieString(url)
}
getCurrentUA() : string {
return UTSiOS.getUserAgent()
}
sendEvent(name : string, params : Dictionary<string, any> | null) {
switch (name) {
case "play":
case "pause":
case "waiting":
case "ended":
case "error":
case "click":
this.component?.__$$emit(name);
break;
case "timeupdate":
case "fullscreenclick":
case "fullscreenchange":
case "controlstoggle":
this.component?.__$$emit(name, params);
break;
default:
break;
}
}
loadImage(url : string, complete : (image : UIImage) => void) {
UTSiOS.loadImage(url, (image, data) => {
if (image != null) {
complete(image!);
}
});
}
lockScreen() {
UTSiOS.lockScreen()
}
unlockScreen() {
UTSiOS.unlockScreen()
}
setFullScreen(yesOrNo : boolean) {
UTSiOS.setFullScreen(yesOrNo)
}
setHomeIndicatorAutoHidden(yesOrNo : boolean) {
UTSiOS.setHomeIndicatorAutoHidden(yesOrNo)
}
setTempOrientation(temp : UIInterfaceOrientationMask) {
UTSiOS.setTempOrientation(temp)
}
configSupportOrientation(orientation : UIInterfaceOrientation) : boolean {
return UTSiOS.configSupportOrientation(orientation)
}
setDeviceInterfaceOrientation(orientation : UIInterfaceOrientation) {
UTSiOS.setDeviceInterfaceOrientation(orientation)
}
h5Path2SysPath(path : string, basePath : string | null) : string {
return UTSiOS.getResourceAbsolutePath(path, basePath)
}
workRootPath() : string {
return UTSiOS.getWorkRootPath()
}
videoPlayerWillEnterFullScreen(orientation : UIInterfaceOrientation) {
this.originalFrame = this.component?.view.frame
const deviceSize = UIScreen.main.bounds.size
const min = min(deviceSize.width, deviceSize.height)
const max = max(deviceSize.width, deviceSize.height)
if (orientation == UIInterfaceOrientation.portrait) {
this.component?.setStyleWidth(width = Float(min))
this.component?.setStyleHeight(height = Float(max))
} else {
this.component?.setStyleWidth(width = Float(max))
this.component?.setStyleHeight(height = Float(min))
}
this.component?.domNode?.setPositionEdge(UniCssFlexEdge.top, value = -Float(this.originalFrame?.minY ?? 0))
this.component?.domNode?.setPositionEdge(UniCssFlexEdge.left, value = -Float(self.originalFrame?.minX ?? 0))
this.component?.setNeedsLayout()
}
videoPlayerWillExitFullScreen(orientation : UIInterfaceOrientation) {
if (this.originalFrame != null) {
const width = this.originalFrame!.size.width
const height = this.originalFrame!.size.height
this.component?.setStyleWidth(width = Float(width))
this.component?.setStyleHeight(height = Float(height))
this.component?.domNode?.setPositionEdge(UniCssFlexEdge.top, value = 0)
this.component?.domNode?.setPositionEdge(UniCssFlexEdge.left, value = 0)
this.component?.setNeedsLayout()
}
}
videoPlayerExitFullScreen(orientation : UIInterfaceOrientation) {
}
videoPlayerEnterFullScreen(orientation : UIInterfaceOrientation) {
}
videoCacheDir() : string {
return UTSiOS.getVideoCacheDir()
}
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册