ResourcePlayerNode
class ResourcePlayerNode
Extends: Node
Package: dev.joid.lib.ui.node.impl.resource · Module: core · Source: ResourcePlayerNode.java
Plays a video or an animated image in its bounds, with its sound, and controls the playback.
Description
Section titled “Description”Each player plays its own copy of the resource, made when the node is attached, so two players of the same resource play separately.
Before that copy exists, play, pause, stop, restart and seek are kept and applied when the playback starts; getPlayback() and getVideo() return null.
The node waits for its resource like a ResourceNode and takes its size the same way.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
ResourcePlayerNode | create(double x, double y) factory | Creates a player at x, y that takes the size of its resource. |
ResourcePlayerNode | create(double x, double y, double width, double height) factory | Creates a player with a declared size; a size of 0 on an axis follows the ratio of the resource. |
| ResourcePlayerNode(double x, double y, double width, double height) protected | Called by a subclass with the same arguments as create. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| resource signal | Resource | null | The video or animated image to play. |
| stretch signal | StretchType | StretchType.STRETCH | How the frames fill the bounds. |
| autoplay signal | boolean | true | If true, the playback starts as soon as the resource is ready; if false, it waits paused on its first frame, an animated image as a video. |
| loop signal | boolean | false | If true, the playback starts again at the end instead of ending. |
| volume signal | float | 1F | Volume of the sound of a video, from 0 for silence to 1 for the full volume. |
| audioGroup signal | Object | null | Group of the sound of a video, for the audio bridge to set the volume of several players at once. |
| location signal | Point | none, the sound plays without position | Position of the sound of a video, whose volume falls with its distance to the position of VideoAudioPlayer.audioListenerPosition; null plays it without position. |
| referenceDistance signal | float | 5, the distance of the video decoder | Distance from location within which the sound plays at full volume; null keeps 5. |
| maxDistance signal | float | 50, the distance of the video decoder | Distance from location from which the sound is silent; in between, the volume falls as (1 − t)², t going from 0 to 1 between the two distances; null keeps 50. |
Inherited from Node (24)
x · y · width · height · position · anchor · anchorX · anchorY · aspectRatio · zindex · zlevel · skeleton · visible · enabled · interactive · cursor · hoverDuration · hoverEquation · hover · overflow · scrollSpeed · scrollbar · label · draggable
Methods
Section titled “Methods”Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
double | getDuration() | Length of the resource, in seconds; 0 before the playback exists. |
double | getProgress() | Share of the resource already played, from 0 to 1. |
IResourcePlayback | getPlayback() | The playback of the copy that this node plays, or null before the node is attached or when the resource has none. |
VideoResourceDecoder | getVideo() | The video decoder of the copy that this node plays, or null when the resource is not a video or the node is not attached. |
boolean | isPaused() | If true, the playback is paused. |
boolean | isPlaying() | If true, the playback is playing. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
this | play() fluent | Starts the playback, or resumes it after a pause or a stop; onPlay fires on the next frame, once the playback runs. |
this | stop() fluent | Stops the playback, back at the start, and fires onStop. |
this | pause() fluent | Pauses a playing resource and fires onPause. |
this | toggle() fluent | Pauses a playing resource, otherwise plays it. |
this | restart() fluent | Plays the resource again from the start. |
this | seek(double seconds) fluent | Moves the playback to this time, in seconds. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | update() hook | Measures the resource on every frame, so that the node takes its size as soon as it loads. |
void | draw(double mouseX, double mouseY) hook | Starts the playback on the first frame, fires the playback events, then draws the current frame. |
void | detach() hook | Releases the copy that this node plays and its sound; attaching the node again starts from the beginning. |
Inherited from Node (128)
load · render · renderHover · updateScroll · updateScrollX · updateScrollY · append · attach · body · clearChildren · getChild · getChildren · getNodeListAt · getParent · isAttached · getAbsoluteX · getAbsoluteY · getAbsoluteDefaultX · getAbsoluteDefaultY · toDrawX · toDrawY · w · h · dw · dh · mw · mh · aw · ah · ax · ay · getDefaultWidth · getDefaultHeight · removeHover · clearHover · refreshHover · getResolvedCursor · hoverValue · getHoverAnimator · isHovered · handleMousePressed · handleMouseReleased · handleMouseDragged · handleMouseScroll · handleCharTyped · handleKeyPressed · handleKeyReleased · getLastClickTime · getLastClickButton · getLastKey · getLastKeyTime · scrollX · scrollY · scrollTo · beforeScroll · hasOverflowX · hasOverflowY · getOverflowArea · getScrollX · getScrollY · getTargetScrollX · getTargetScrollY · getMaxScrollX · getMaxScrollY · isScrollEndX · isScrollEndY · startDragging · stopDragging · beforeDragStart · beforeDragDrop · isDragging · getDragX · getDragY · isDragged · getDragSource · getDraggedNode · getStartDragX · getStartDragY · getTargetDragX · getTargetDragY · effect · removeEffect · clearEffects · hasEffect · getEffect · layer · clearLayers · animate · removeAnimator · wait · watch · hasListener · isVisibleProperty · isMounted · getIndex · getUi · getHierarchy · getMappedIndex · getTaskList · getShortcutList · toJson · toString · getEventBus · getBodyConsumer · getDefaultX · getDefaultY · getLayoutX · getLayoutY · getShiftX · getShiftY · isStepping · getLastCodepoint · getLoadCount · getRenderTime · remove · self · copy · useStore · addTask · removeTask · addShortcut · removeShortcut · layoutPosition · layoutSize · fit · move · beforeMove · hoverColor
Events
Section titled “Events”| Event | Listener | Summary |
|---|---|---|
| onPlay | EventListener<NodeEvent<T>> | Adds a listener that runs when the playback starts or resumes. |
| onPause | EventListener<NodeEvent<T>> | Adds a listener that runs when the playback pauses. |
| onStop | EventListener<NodeEvent<T>> | Adds a listener that runs when the playback stops, by stop() or at the end of a resource that does not loop. |
| onEnd | EventListener<NodeEvent<T>> | Adds a listener that runs when a resource that does not loop reaches its end, before onStop. |
| onProgress | EventListener<NodeProgressEvent<T>> | Adds a listener that runs on every frame where the progress changes, with the progress and the current time. |
Inherited from Node (21)
onUpdate · onDetach · onInit · onRender · onDraw · onMount · onHoverStart · onHover · onHoverEnd · onScroll · onScrollToEnd · onScrollEndReached · onDragStart · onDrag · onDragDrop · onDragSnap · onMove · onChildAppend · onClick · onAnimate · onWatch
Creation details
Section titled “Creation details”create
Section titled “create”ResourcePlayerNode create(double x, double y) factory
Creates a player at x, y that takes the size of its resource.
ResourcePlayerNode create(double x, double y, double width, double height) factory
Creates a player with a declared size; a size of 0 on an axis follows the ratio of the resource.
ResourcePlayerNode
Section titled “ResourcePlayerNode”ResourcePlayerNode(double x, double y, double width, double height) protected
Called by a subclass with the same arguments as create.
Property details
Section titled “Property details”resource
Section titled “resource”this resource(Resource resource)fluentthis resource(Supplier<Resource> resource)fluent signalResource getResource()
Default: null
The video or animated image to play.
Another resource restarts the playback; the same resource with the same properties keeps it.
Throws an IllegalStateException when the node is attached without one.
stretch
Section titled “stretch”this stretch(StretchType stretch)fluentthis stretch(Supplier<StretchType> stretch)fluent signalStretchType getStretch()
Default: StretchType.STRETCH
How the frames fill the bounds.
autoplay
Section titled “autoplay”this autoplay(boolean autoplay)fluentthis autoplay(Supplier<Boolean> autoplay)fluent signalboolean isAutoplay()
Default: true
If true, the playback starts as soon as the resource is ready; if false, it waits paused on its first frame, an animated image as a video.
this loop(boolean loop)fluentthis loop(Supplier<Boolean> loop)fluent signalboolean isLoop()
Default: false
If true, the playback starts again at the end instead of ending.
volume
Section titled “volume”this volume(float volume)fluentthis volume(Supplier<Float> volume)fluent signalfloat getVolume()
Default: 1F
Volume of the sound of a video, from 0 for silence to 1 for the full volume.
audioGroup
Section titled “audioGroup”this audioGroup(Object audioGroup)fluentthis audioGroup(Supplier<?> audioGroup)fluent signalObject getAudioGroup()
Default: null
Group of the sound of a video, for the audio bridge to set the volume of several players at once.
location
Section titled “location”this location(Point location)fluentthis location(Supplier<Point> location)fluent signalPoint getLocation()
Default: none, the sound plays without position
Position of the sound of a video, whose volume falls with its distance to the position of VideoAudioPlayer.audioListenerPosition; null plays it without position.
referenceDistance
Section titled “referenceDistance”this referenceDistance(float referenceDistance)fluentthis referenceDistance(Supplier<Float> referenceDistance)fluent signalFloat getReferenceDistance()
Default: 5, the distance of the video decoder
Distance from location within which the sound plays at full volume; null keeps 5.
maxDistance
Section titled “maxDistance”this maxDistance(float maxDistance)fluentthis maxDistance(Supplier<Float> maxDistance)fluent signalFloat getMaxDistance()
Default: 50, the distance of the video decoder
Distance from location from which the sound is silent; in between, the volume falls as (1 − t)², t going from 0 to 1 between the two distances; null keeps 50.
Method details
Section titled “Method details”getDuration
Section titled “getDuration”double getDuration()
Length of the resource, in seconds; 0 before the playback exists.
getProgress
Section titled “getProgress”double getProgress()
Share of the resource already played, from 0 to 1.
getPlayback
Section titled “getPlayback”IResourcePlayback getPlayback()
The playback of the copy that this node plays, or null before the node is attached or when the resource has none.
getVideo
Section titled “getVideo”VideoResourceDecoder getVideo()
The video decoder of the copy that this node plays, or null when the resource is not a video or the node is not attached.
isPaused
Section titled “isPaused”boolean isPaused()
If true, the playback is paused.
isPlaying
Section titled “isPlaying”boolean isPlaying()
If true, the playback is playing.
this play() fluent
Starts the playback, or resumes it after a pause or a stop; onPlay fires on the next frame, once the playback runs.
Throws an IllegalStateException when the resource has no playback, such as a still image.
this stop() fluent
Stops the playback, back at the start, and fires onStop.
this pause() fluent
Pauses a playing resource and fires onPause.
toggle
Section titled “toggle”this toggle() fluent
Pauses a playing resource, otherwise plays it.
restart
Section titled “restart”this restart() fluent
Plays the resource again from the start.
this seek(double seconds) fluent
Moves the playback to this time, in seconds. A stopped resource pauses at that time and shows its frame.
update
Section titled “update”void update() hook
Measures the resource on every frame, so that the node takes its size as soon as it loads.
void draw(double mouseX, double mouseY) hook
Starts the playback on the first frame, fires the playback events, then draws the current frame.
detach
Section titled “detach”void detach() hook
Releases the copy that this node plays and its sound; attaching the node again starts from the beginning.
Event details
Section titled “Event details”onPlay
Section titled “onPlay”this onPlay(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs when the playback starts or resumes.
onPause
Section titled “onPause”this onPause(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs when the playback pauses.
onStop
Section titled “onStop”this onStop(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs when the playback stops, by stop() or at the end of a resource that does not loop.
this onEnd(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs when a resource that does not loop reaches its end, before onStop.
onProgress
Section titled “onProgress”this onProgress(EventListener<NodeProgressEvent<T>> listener) fluent
Adds a listener that runs on every frame where the progress changes, with the progress and the current time.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
