A PocketMine-MP library to play videos on maps. You can find an example of how to use this library in a plugin here.
First you need to register the library. Simply do:
\Jibix\MapVideo\MapVideo::initialize($plugin);
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();
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();