Constructor
new File(player, parent, optionsopt)
Creates an instance of the File component.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
player |
Player |
Reference to the VisionPlayer instance. |
|||||||||
parent |
Controller |
The parent container, in this case the controller. |
|||||||||
options |
Object | optional |
Additional options.
|
Members
private #config :Object
Contains configuration options for how files are handled.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
fileDrop
|
boolean | optional | true | Enables drag & drop file upload. |
fileSelector
|
boolean | optional | true | Enables the file selection button in the controller. |
fileSelectorAccept
|
boolean | optional | true | If |
private #player :Player
private #button :DomSmith
private #dropZone :DomSmith
private #blobs :Array
Methods
private #fileSelected(event)
Handler for file selection via the file input or drag'n'drop event. Creates an array of file objects with properties:
- title: File name.
- ext: File extension.
- src: Blob URL created from the file.
- type: MIME type of the file. Then sets the media data for the player by creating a playlist of the selcted files.
| Name | Type | Description |
|---|---|---|
event |
Event |
The change event from the file input. |
private #onZoneDragEnter(event)
Handles the dragenter event on the drop zone. Displays a visual indication that the file can be dropped.
| Name | Type | Description |
|---|---|---|
event |
DragEvent |
The dragenter event. |
private #onZoneDragLeave(event)
Handles the dragleave event on the drop zone. Removes the visual drag indicator.
| Name | Type | Description |
|---|---|---|
event |
DragEvent |
The dragleave event. |
private #onZoneDrop(event)
Handles the drop, by extracting the associated files from the drop event.
| Name | Type | Description |
|---|---|---|
event |
DragEvent |
The originating drag event. |
private #onWinDragOver(event)
Handles the dragenter event on the window. Visually activates the inner drop zone.
| Name | Type | Description |
|---|---|---|
event |
DragEvent |
The dragenter event. |
private #onWinDragLeave(event)
Handles the dragleave event on the window. Visually deactivates the inner drop zone.
| Name | Type | Description |
|---|---|---|
event |
DragEvent |
The dragleave event. |
private #isFileDrag(event) → boolean
Helper function to determine whether the drag event contains files.
| Name | Type | Description |
|---|---|---|
event |
DragEvent |
The originating drag event. |