Skip to main content

LensStudio:Ui.VideoView

Class

Widget for displaying video content.

Index

Example

export class VideoViewPanel extends PanelPlugin {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.VideoViewExample';
d.name = 'VideoView Example';
d.defaultDockState = DockState.Detached;
d.defaultSize = new Size(400, 350);
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
}
createWidget(parent: Widget): Widget {
const root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
layout.spacing = 8;
root.layout = layout;

const title = new Label(root);
title.text = 'VideoView Demo';
title.fontRole = FontRole.TitleBold;
layout.addWidget(title);

// VideoView embeds a video player in the panel
const video = new VideoView(root);
video.setSource(new Editor.Path('preview.mp4'));
video.loopCount = -1;
video.muted = true;
video.setMinimumHeight(200);
layout.addWidget(video);

const playBtn = new PushButton(root);
playBtn.text = 'Play';
layout.addWidget(playBtn);

const pauseBtn = new PushButton(root);
pauseBtn.text = 'Pause';
layout.addWidget(pauseBtn);

this.connections.push(
playBtn.onClick.connect(() => {
video.play();
}),
pauseBtn.onClick.connect(() => {
video.pause();
}),
video.onPositionChanged.connect((pos: number) => {
console.log('Position:', pos);
})
);

return root;
}
deinit(): void {
this.connections.forEach((c: any) => c?.disconnect());
this.connections = [];
}
}

Extends

Constructors

Constructor

new VideoView(parent): VideoView

Constructs a new VideoView widget for embedding video playback inside a plugin panel.

Parameters

ParameterType
parentWidget

Returns

VideoView

Overrides

Widget.constructor

Properties

autoFillBackground

autoFillBackground: boolean

Whether the widget automatically fills its background before painting.

Inherited from

Widget.autoFillBackground


backgroundRole

backgroundRole: ColorRole

The color role used for the widget's background.

Inherited from

Widget.backgroundRole


className

readonly className: string

Class name of the underlying widget type.

Inherited from

Widget.className


contextMenuPolicy

contextMenuPolicy: ContextMenuPolicy

Controls how the widget handles context menu requests.

Inherited from

Widget.contextMenuPolicy


devicePixelRatio

readonly devicePixelRatio: number

The ratio between physical and logical pixels for the widget's display.

Inherited from

Widget.devicePixelRatio


duration

readonly duration: number

Total duration of the loaded video in seconds.


enabled

enabled: boolean

Whether the widget is interactive and accepts user input.

Inherited from

Widget.enabled


fontRole

fontRole: FontRole

The font role applied to the widget's text rendering.

Inherited from

Widget.fontRole


foregroundRole

foregroundRole: ColorRole

The color role used for the widget's foreground elements.

Inherited from

Widget.foregroundRole


hasFocus

readonly hasFocus: boolean

True when the widget currently holds keyboard focus.

Inherited from

Widget.hasFocus


height

readonly height: number

Current height of the widget in pixels.

Inherited from

Widget.height


hidden

hidden: boolean

Whether the widget is hidden from view.

Inherited from

Widget.hidden


isNull

readonly isNull: boolean

True if the underlying native widget object has been destroyed.

Inherited from

Widget.isNull


isTransparentForMouseEvents

isTransparentForMouseEvents: boolean

When true, mouse events pass through the widget to widgets below.

Inherited from

Widget.isTransparentForMouseEvents


layout

layout: Layout

The layout manager assigned to arrange child widgets.

Inherited from

Widget.layout


loopCount

loopCount: number

Number of times the video will loop; -1 for infinite looping.


muted

muted: boolean

Whether the video audio is muted.


objectName

objectName: string

Identifier by which the widget can be located via findChild.

Inherited from

Widget.objectName


onClick

readonly onClick: signal0<void>

Callback fired when the video view is clicked.


onClose

readonly onClose: signal1<CloseEvent, void>

Signal emitted when the widget is closed.

Inherited from

Widget.onClose


onFocusIn

readonly onFocusIn: signal0<void>

Emitted when the widget gains keyboard focus.

Inherited from

Widget.onFocusIn


onFocusOut

readonly onFocusOut: signal0<void>

Emitted when the widget loses keyboard focus.

Inherited from

Widget.onFocusOut


onHide

readonly onHide: signal0<void>

Signal emitted when the widget becomes hidden.

Inherited from

Widget.onHide


onHover

readonly onHover: signal1<boolean, void>

Callback fired when the pointer enters or leaves the video view.


onKeyPress

readonly onKeyPress: signal1<number, void>

Signal emitted when a key is pressed while the widget has focus.

Inherited from

Widget.onKeyPress


onMouseDoubleClick

readonly onMouseDoubleClick: signal1<MouseEvent, void>

Signal emitted when the user double-clicks on the widget.

Inherited from

Widget.onMouseDoubleClick


onMouseMove

readonly onMouseMove: signal1<MouseEvent, void>

Signal emitted when the mouse moves over the widget.

Inherited from

Widget.onMouseMove


onMousePress

readonly onMousePress: signal1<MouseEvent, void>

Signal emitted when a mouse button is pressed on the widget.

Inherited from

Widget.onMousePress


onMouseRelease

readonly onMouseRelease: signal1<MouseEvent, void>

Signal emitted when a mouse button is released on the widget.

Inherited from

Widget.onMouseRelease


onPositionChanged

readonly onPositionChanged: signal1<number, void>

Callback fired when the playback position changes.


onResize

readonly onResize: signal2<number, number, void>

Signal emitted when the widget is resized.

Inherited from

Widget.onResize


onShow

readonly onShow: signal0<void>

Signal emitted when the widget becomes visible.

Inherited from

Widget.onShow


onStateChanged

readonly onStateChanged: signal1<any, void>

Callback fired when the playback state changes.


position

position: number

Current playback position in seconds.


radius

radius: number

Corner radius of the video view widget.


responseHover

responseHover: boolean

Whether the widget responds to hover events.


state

readonly state: any

Current playback state of the video.


toolTip

toolTip: string

Text displayed in a tooltip when the user hovers over the widget.

Inherited from

Widget.toolTip


visible

visible: boolean

Whether the widget is currently visible.

Inherited from

Widget.visible


volume

volume: number

Playback volume level, from 0.0 to 1.0.


width

readonly width: number

Current width of the widget in pixels.

Inherited from

Widget.width


windowTitle

windowTitle: string

Title text displayed in the widget's title bar when shown as a window.

Inherited from

Widget.windowTitle

Methods

actions()

actions(): Action[]

Returns

Action[]

Inherited from

Widget.actions


activateWindow()

activateWindow(): void

Brings the widget's top-level window to the foreground and gives it focus.

Returns

void

Inherited from

Widget.activateWindow


adjustSize()

adjustSize(): void

Resizes the widget to fit its contents based on the size hint.

Returns

void

Inherited from

Widget.adjustSize


blockSignals()

blockSignals(blocked): void

Blocks or unblocks signal emission from the widget.

Parameters

ParameterType
blockedboolean

Returns

void

Inherited from

Widget.blockSignals


close()

close(): void

Closes the widget, hiding it and emitting the onClose signal.

Returns

void

Inherited from

Widget.close


deleteLater()

deleteLater(): void

Schedules the widget for deletion after the current event loop iteration.

Returns

void

Inherited from

Widget.deleteLater


findChild()

findChild(objectName): Widget

Returns the descendant widget with the given object name, or null if none matches.

Parameters

ParameterType
objectNamestring

Returns

Widget

Inherited from

Widget.findChild


getProperty()

getProperty(name): any

Returns the value of the dynamic property with the given name.

Parameters

ParameterType
namestring

Returns

any

Inherited from

Widget.getProperty


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

Widget.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Widget.getTypeName


grab()

grab(): Pixmap

Captures the widget's current rendered content as a Pixmap.

Returns

Pixmap

Inherited from

Widget.grab


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Widget.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Widget.isSame


mapToGlobal()

mapToGlobal(x, y): Point

Parameters

ParameterType
xnumber
ynumber

Returns

Point

Inherited from

Widget.mapToGlobal


move()

move(ax, ay): void

Moves the widget to the specified position.

Parameters

ParameterType
axnumber
aynumber

Returns

void

Inherited from

Widget.move


pause()

pause(): void

Pauses the currently playing video.

Returns

void


play()

play(): void

Starts or resumes video playback.

Returns

void


raise()

raise(): void

Raises the widget to the top of the parent widget's stack.

Returns

void

Inherited from

Widget.raise


resize()

resize(width, height): void

Resizes the widget to the specified width and height.

Parameters

ParameterType
widthnumber
heightnumber

Returns

void

Inherited from

Widget.resize


setContentsMargins()

setContentsMargins(left, top, right, bottom): void

Sets the margins around the widget's contents.

Parameters

ParameterType
leftnumber
topnumber
rightnumber
bottomnumber

Returns

void

Inherited from

Widget.setContentsMargins


setCursor()

setCursor(shape): void

Sets the cursor shape displayed when the mouse is over the widget.

Parameters

ParameterType
shapeCursorShape

Returns

void

Inherited from

Widget.setCursor


setCursorPixmap()

setCursorPixmap(pixmap): void

Sets a custom pixmap as the cursor when the mouse is over the widget.

Parameters

ParameterType
pixmapPixmap

Returns

void

Inherited from

Widget.setCursorPixmap


setFixedHeight()

setFixedHeight(height): void

Locks the widget's height to the given value, preventing resizing.

Parameters

ParameterType
heightnumber

Returns

void

Inherited from

Widget.setFixedHeight


setFixedWidth()

setFixedWidth(width): void

Locks the widget's width to the given value, preventing resizing.

Parameters

ParameterType
widthnumber

Returns

void

Inherited from

Widget.setFixedWidth


setFocus()

setFocus(): void

Gives keyboard input focus to the widget.

Returns

void

Inherited from

Widget.setFocus


setMaximumHeight()

setMaximumHeight(height): void

Sets the maximum height the widget can be resized to.

Parameters

ParameterType
heightnumber

Returns

void

Inherited from

Widget.setMaximumHeight


setMaximumWidth()

setMaximumWidth(width): void

Sets the maximum width the widget can be resized to.

Parameters

ParameterType
widthnumber

Returns

void

Inherited from

Widget.setMaximumWidth


setMinimumHeight()

setMinimumHeight(height): void

Sets the minimum height the widget must maintain.

Parameters

ParameterType
heightnumber

Returns

void

Inherited from

Widget.setMinimumHeight


setMinimumWidth()

setMinimumWidth(width): void

Sets the minimum width the widget must maintain.

Parameters

ParameterType
widthnumber

Returns

void

Inherited from

Widget.setMinimumWidth


setProperty()

setProperty(name, value): boolean

Sets the dynamic property with the given name to the given value.

Parameters

ParameterType
namestring
valueany

Returns

boolean

Inherited from

Widget.setProperty


setSizePolicy()

setSizePolicy(horizontal, vertical): void

Controls how the widget grows or shrinks relative to its layout.

Parameters

ParameterType
horizontalPolicy
verticalPolicy

Returns

void

Inherited from

Widget.setSizePolicy


setSource()

setSource(path): void

Sets the video file to play from the given path.

Parameters

ParameterType
pathPath

Returns

void


setUndoable()

setUndoable(undoable): void

Marks property changes on this widget as undoable via the undo stack.

Parameters

ParameterType
undoableboolean

Returns

void

Inherited from

Widget.setUndoable


setUndoableRecursive()

setUndoableRecursive(undoable): void

Marks property changes on this widget and all its children as undoable.

Parameters

ParameterType
undoableboolean

Returns

void

Inherited from

Widget.setUndoableRecursive


show()

show(): void

Makes the widget visible.

Returns

void

Inherited from

Widget.show


stop()

stop(): void

Stops video playback and resets to the beginning.

Returns

void


unsetCursor()

unsetCursor(): void

Resets the cursor to the parent widget's cursor.

Returns

void

Inherited from

Widget.unsetCursor