1. Description and Objectives
ImgurVideoPlayer adds video playback capabilities to the Imgur Media Search plugin. Its main objectives are to:
- Play Imgur videos by extracting the video ID from the provided URL.
- Display an initial poster that is automatically fetched or dynamically generated if needed.
- Optimize performance by initializing the player only when the component is visible (lazy loading).
2. Configuration Fields
When setting up the ImgurVideoPlayer, you can configure the following fields:
- url (required):
The complete URL of the Imgur video to be played.
- poster (optional):
An image URL to use as the initial poster. If not specified, the system will attempt to fetch or generate one.
- standardWidth (optional):
The standard width for the player (default: 320).
- standardHeight (optional):
The standard height for the player (default: 180).
- standardRatio (optional):
The aspect ratio for the player (default: "16:9").
- autoplay (optional):
Determines whether the video should start playing automatically.
- muted (optional):
If true, the video will start with the sound off.
- loop (optional):
If set, the video will replay in a loop.
- preload (optional):
The preload setting for the video (e.g., "auto", "none").
- volume (optional):
The initial volume level (from 0 to 1).
- playbackRate (optional):
The initial playback speed (default: 1).
- controls (optional):
Whether to show the player controls.
3. Exposed States
The ImgurVideoPlayer updates and publishes several states for you to monitor the player:
- duration:
Total duration of the video.
- currentTime:
The current playback time of the video.
- paused:
Indicates if the video is paused.
- ended:
Indicates if the video has finished.
- buffered:
The loading progress shown as a percentage.
- volume:
The current volume level.
- muted:
Whether the video is muted.
- playbackRate:
The current playback speed.
- seeking:
Indicates if the user is seeking (changing the playback position).
- ready:
Shows if the player is fully initialized and ready for playback.
- error:
Contains an error message if something goes wrong.
- playerWidth / playerHeight:
The current dimensions of the player.
- videoWidth / videoHeight:
The intrinsic resolution of the video.
4. Internal Events
The player manages various events to update its states and ensure proper operation:
- Metadata Loaded:
When the video metadata is available, it sets the duration and intrinsic video dimensions.
- Time Update:
The current time and buffering progress are continuously updated during playback.
- Playback Changes:
When the video plays, pauses, or stops, the appropriate states are updated.
- Volume and Speed Changes:
Any modifications to the volume or playback speed update the corresponding states.
- Error Detection:
If an error occurs, the player captures the message and makes it available in the exposed states.
5. Action Elements
ImgurVideoPlayer provides several actions to control the video:
- play:
Starts video playback.
- pause:
Pauses the video.
- stop:
Stops playback and resets the video to the beginning.
- seekTo(time):
Jumps to a specific time (in seconds).
- setVolume(volume):
Adjusts the volume (between 0 and 1).
- mute:
Mutes the video.
- unmute:
Unmutes the video.
- restart:
Restarts the video from the beginning.
Comments (00)