PlayerController class
Controls the native iOS video player.
Create one controller per PlayerView widget. After the widget is inserted into the tree, the underlying MethodChannel is ready and all methods can be called.
Constructors
Properties
-
eventStream
→ Stream<
PlayerEvent> -
Stream of native player events (ready, playstatechange, timeupdate, …).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addArrayBarrageText(
List< String> texts, String textColor, double speed) → Future<void> -
addBarrageText(
String text, String textColor, double speed) → Future< void> -
cleanBarrageQueue(
) → Future< void> -
clearBarrage(
) → Future< void> -
clearProgressMarkerPoints(
) → Future< void> -
connectDLNADevice(
String deviceId) → Future< void> -
connectPlatformView(
int viewId) → void -
Public entry point for platform-view creation. Functionally identical to
_onPlatformViewCreated; exposed so composite widgets (e.g. PlayerViewWithControls) can forward the callback without subclassing. -
destroy(
) → Future< void> -
disconnectDLNADevice(
) → Future< void> -
dispose(
) → void -
dlnaGetPositionInfo(
) → Future< void> -
dlnaGetVolume(
) → Future< void> -
dlnaPause(
) → Future< void> -
dlnaPlay(
) → Future< void> -
dlnaSeekToTime(
int seconds) → Future< void> -
Seek DLNA device to
seconds(converted to HH:MM:SS internally). -
dlnaSetMute(
bool muted) → Future< void> -
dlnaSetURL(
String url) → Future< void> -
dlnaSetVolume(
int volume) → Future< void> -
dlnaStartPositionPolling(
) → Future< void> -
dlnaStop(
) → Future< void> -
dlnaStopPositionPolling(
) → Future< void> -
enterFullscreen(
) → Future< void> -
enterPIP(
) → Future< void> -
exitFullscreen(
) → Future< void> -
exitPIP(
) → Future< void> -
forceOrientationToLandscape(
) → Future< void> -
forceOrientationToPortrait(
) → Future< void> -
getBrightness(
) → Future< double> -
getCurrentTime(
) → Future< double> - Returns the current playback position in seconds.
-
getCurrentVideoDisplayInfo(
) → Future< Map< String, dynamic> > - Returns current video display info after the first valid video size arrives.
-
getDLNADevices(
) → Future< void> -
getDuration(
) → Future< double> - Returns the total duration in seconds.
-
getVolume(
) → Future< double> -
hideToast(
) → Future< void> -
lockOrientation(
bool locked) → Future< void> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → Future< void> -
play(
String url, {Map< String, String> ? headers, String? platform}) → Future<void> - Load and play a video URL (mp4 / m3u8 / local file path).
-
playEncrypted(
String url, {required String decryptionKey}) → Future< void> -
Play an encrypted video with the given
decryptionKey. -
playHuolong(
String url) → Future< void> - 火龙 VVC 转码播放(阶段1独立入口)。 Android: HuolongPlayer 下载 TS → FFmpeg VVC→H.264 转码 → ExoPlayer 播放。
-
playWithAds(
{required String url, required String adsUrl, int countDown = 15, String? landingUrl, Map< String, String> ? headers}) → Future<void> -
Play with a pre-roll ad video before the main content.
landingUrlis opened when the user taps "了解详情" on the ad overlay. -
playWithResourceLoad(
String url, {Map< String, String> ? headers}) → Future<void> - Play with HEVC resource-loader pre-processing (hev1→hvc1 fix).
-
restoreSystemUI(
) → Future< void> - 还原系统 UI(status bar / navigation bar)到进入短剧前 saved 的可见性。
-
resume(
) → Future< void> -
seek(
double position) → Future< void> -
Seek to
positionseconds. -
seekToSeconds(
double seconds) → Future< void> -
Precise seek to
seconds. Works in both normal and shortDrama modes. Negative values are clamped to 0; values beyond duration are clamped toduration - 0.5on the native side. No-op during ad playback. -
setBackButtonInsets(
{double? top, double? left}) → Future< void> -
Customise the portrait (non-fullscreen) back-button inset.
Pass
topand/orleftin points. Either argument may be null to keep the corresponding default (top=8, left=15). Pass both as null to reset. -
setBarrageRowsNumber(
int rows) → Future< void> -
setBarrageSettings(
{double? displayAreaRatio, double? opacity, double? fontSize, double? speedLevel}) → Future< void> - 批量设置弹幕显示参数,所有字段均可选。
-
setBarrageVisible(
bool visible) → Future< void> -
setBrightness(
double brightness) → Future< void> -
Set screen brightness
0.0 – 1.0. -
setButtonImages(
Map< String, String> images) → Future<void> - Set custom button images. Each key matches a button name (e.g. 'play', 'pause', 'fullscreen', …) and each value is a base-64 encoded image.
-
setControlBarVisible(
bool visible) → Future< void> - Show or hide the control bar (play/pause, progress slider, etc.). Defaults to visible. When hidden, tap gestures will not show the controls.
-
setCoverImage(
String url) → Future< void> - 后台/锁屏 NowPlaying 卡片左上角封面图 URL。传空串清空。 原生侧自带 URL 去重 + 异步下载 + 失败退避,重复调用零成本。
-
setEpisodeSelectorAd(
String imageURL, String title, String subtitle) → Future< void> -
setFitMode(
PlayerFitMode mode) → Future< void> - 运行时切换画面填充模式,无需重建 widget。
-
setGravityRotationEnabled(
bool enabled) → Future< void> -
Enable or disable gravity-based (sensor) orientation detection.
When
enabledis false, tilting the device no longer triggers fullscreen / portrait switches — only explicit button taps or API calls (enterFullscreen / exitFullscreen) work. -
setLoadFailureDetection(
{int firstFrameTimeoutSec = 15, int stallTimeoutSec = 15}) → Future< void> -
配置加载失败检测。loading 超时(起播拿不到首帧 / 中途卡顿迟迟不恢复)时,
原生侧停止 loading 并通过
error事件上报,detail 含reason(见 PlayerLoadFailureReason),由宿主展示「加载失败/点击重试」。 不做断网检测:超时是结果导向,命中缓存能播就不会触发,与缓存等业务无关; 断网判断交给宿主(如 connectivity_plus),收到 load_timeout 后宿主可结合 网络状态决定文案(无网 vs 播放地址失效)。默认 15s/15s。 -
setLoadingGif(
String base64, String text) → Future< void> -
setMuted(
bool muted) → Future< void> -
setNativeUIVisible(
bool visible) → Future< void> - Show or hide the native player control UI.
-
setPausePopupAdURL(
{required String portraitURL, required String landscapeURL}) → Future< void> -
setPiPEnabled(
bool enabled) → Future< void> -
setPlaybackQuality(
int quality) → Future< void> - 指定当前播放分辨率 / 默认选中画质。
-
setPlayerMode(
PlayerMode mode) → Future< void> - Switch the player between normal and short-drama mode. In short-drama mode, mid-screen pan gestures are fully disabled by the native layer and no event is dispatched — the host app is expected to handle vertical/horizontal swipes (episode switching, etc.) itself.
-
setPlayerTitle(
String title) → Future< void> -
setPlayingGifImage(
String base64) → Future< void> -
setPortraitBackButtonVisible(
bool visible) → Future< void> - Show or hide the back button in portrait (non-fullscreen) mode.
-
setProgressMarkerPoints(
List< Map< points) → Future<String, dynamic> >void> -
setProgressSliderColor(
String hexColor) → Future< void> -
setProgressSliderHeight(
double height) → Future< void> -
setProgressSliderThumbImage(
String base64) → Future< void> - 设置进度条滑块图片,传入 base64 编码的图片字符串。
-
setRate(
double rate) → Future< void> - Set playback speed (e.g. 0.5, 1.0, 1.5, 2.0).
-
setSeekFeedbackMode(
int mode) → Future< void> -
mode0 = time only, 1 = thumbnail preview, 2 = realtime seek. -
setSelectorAdImage(
String imageURL, String adSpaceType) → Future< void> -
setVideoCurrentQuality(
int quality) → Future< void> -
setVolume(
double volume) → Future< void> -
Set system volume
0.0 – 1.0. -
showEpisodeSelector(
Map< String, dynamic> config) → Future<void> -
showToast(
String text, {String buttonText = '', String buttonColor = '#FFFFFF'}) → Future< void> -
startDLNADiscovery(
) → Future< void> -
stop(
) → Future< void> -
stopDLNADiscovery(
) → Future< void> -
togglePlay(
) → Future< void> - Toggle play/pause: if playing → pause, if paused → play.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCurrentEpisode(
int episode) → Future< void> -
updateDecryptionKey(
String decryptionKey) → Future< void> - Set the decryption key before calling play or playWithResourceLoad.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited