| 17 | { |
| 18 | |
| 19 | VideoScreen::VideoScreen(const UString &videoPath, sp<Stage> nextScreen) |
| 20 | : Stage(), nextScreen(nextScreen) |
| 21 | { |
| 22 | if (videoPath != "") |
| 23 | { |
| 24 | this->video = fw().data->loadVideo(videoPath); |
| 25 | if (!this->video) |
| 26 | { |
| 27 | LogWarning("Failed to load video \"%s\"", videoPath); |
| 28 | } |
| 29 | else |
| 30 | { |
| 31 | // Scale keeping aspect ratio to the max of the screen size |
| 32 | Vec2<float> unscaled_frame_size = this->video->getVideoSize(); |
| 33 | Vec2<float> display_size = fw().displayGetSize(); |
| 34 | Vec2<float> scale_factors = display_size / unscaled_frame_size; |
| 35 | float scale = std::min(scale_factors.x, scale_factors.y); |
| 36 | this->frame_size = unscaled_frame_size * scale; |
| 37 | LogInfo("Scaling video from %s to %s", this->video->getVideoSize(), this->frame_size); |
| 38 | this->frame_position = (fw().displayGetSize() / 2) - (this->frame_size / 2); |
| 39 | } |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | LogInfo("No video"); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | void VideoScreen::begin() |
| 48 | { |
nothing calls this directly
no test coverage detected