jibix/map-video

There is no license information available for the latest version (dev-master) of this package.

dev-master 2024-04-20 16:37 UTC

This package is auto-updated.

Last update: 2024-04-20 16:37:30 UTC


README

php api

A PocketMine-MP library to play videos on maps. You can find an example of how to use this library in a plugin here.

MapVideo

Registration

First you need to register the library. Simply do:

\Jibix\MapVideo\MapVideo::initialize($plugin);

Video loading

Load a video:

VideoManager::getInstance()->loadVideo(
    Video::id("my_video_name"),
    "/path/to/video.gif", //Only .gif files are supported at the moment
    static function (Video $video): void{
        //Do something (you could play the video for example)
    },
    static function (int $totalFrames, int $loadedFrames): void{
        $percentage = round($loadedFrames / $loadedFrames * 100);
        //Do something (you could send a progress bar to the player for example, since this is called in the main thread)
    },
    true //Set to false if you don't want to cache the video
);

Get a cached video:

VideoManager::getInstance()->getCachedVideo($videoId);

Get all cached videos:

$videos = VideoManager::getInstance()->getCachedVideos();

Video playing

Play a video:

$videoSettings = new VideoPlaySettings(
    repeat: true, //Automatically restarts when the video ends
    offHand: false //Set to true if you want to play the video in the off-hand
    //Ideas for more options? Just make an issue!
);
VideoSession::get($player)->play($video, $videoSettings);

Stop a video:

VideoSession::get($player)->stop();

Get the currently playing video:

$video = VideoSession::get($player)->getVideo();