jibix / map-video
该包最新版本(dev-master)没有可用的许可证信息。
dev-master
2024-07-24 14:15 UTC
Requires
- ext-gd: *
- ext-igbinary: *
- sybio/gif-frame-extractor: dev-master
This package is auto-updated.
Last update: 2024-09-24 14:43:04 UTC
README
A PocketMine-MP 库,用于在地图上播放视频。您可以在这里找到一个使用此库的插件示例。
注册
首先您需要注册库。只需执行以下操作
\Jibix\MapVideo\MapVideo::initialize($plugin);
视频加载
加载视频
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 );
获取缓存的视频
VideoManager::getInstance()->getCachedVideo($videoId);
获取所有缓存的视频
$videos = VideoManager::getInstance()->getCachedVideos();
视频播放
播放视频
$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);
停止视频
VideoSession::get($player)->stop();
获取当前播放的视频
$video = VideoSession::get($player)->getVideo();