Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

generate_videojs_options()

Description

Generate JSON array of VideoJS options to be used in the data-setup attribute

Parameters

ColumnTypeDefaultDescription
$view_as_gif bool True if the video is a GIF file
$play_on_hover bool True if playing video on hover
$video_preview_sources array Array of preview sources, including URL, type and label

Return

string|false

Location

include/video_functions.php lines 108 to 151

Definition

 
function generate_videojs_options(bool $view_as_gifbool $play_on_hover, array $video_preview_sources)
{
    global 
$videojs_resolution_selection$videojs_resolution_selection_default_res;

    
$data_setup = ["playbackRates" => [0.511.52]];

    if (
$view_as_gif) {
        
$data_setup array_merge($data_setup, [
            
"controls" => false,
            
"autoplay" => true,
            
"loop" => true,
            
"muted" => true
        
]);
    }

    if (
$play_on_hover && !$view_as_gif) {
        
$data_setup array_merge($data_setup, [
            
"loadingSpinner" => false,
            
"TextTrackDisplay" => true,
            
"nativeTextTracks" => false,
            
"children" => [
                
"bigPlayButton" => false,
                
"controlBar" => [
                    
"children" => [
                        
"playToggle" => false,
                        
"volumeControl" => false
                    
]
                ]
            ]
        ]);
    }

    if (isset(
$videojs_resolution_selection) && count($video_preview_sources) > && !$view_as_gif) {
        
$data_setup array_merge($data_setup, [
            
"plugins" => [
                
"videoJsResolutionSwitcher" => [
                    
"default" => $videojs_resolution_selection_default_res
                
]
            ]
        ]);
    }

    return 
json_encode($data_setup);
}

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 10th September 2024 23:10 Europe/London time.