2024-10-08 14:34:52 +08:00
|
|
|
#include "UtilTool.h"
|
|
|
|
#include "mediaService.h"
|
|
|
|
#include <SFML/Graphics.hpp>
|
2024-09-30 13:34:05 +08:00
|
|
|
#include <SFML/Graphics/RenderWindow.hpp>
|
2024-06-18 10:04:50 +08:00
|
|
|
#include <SFML/System.hpp>
|
|
|
|
#include <SFML/Window.hpp>
|
2024-10-08 14:34:52 +08:00
|
|
|
#include <cstdio>
|
2024-06-18 11:16:30 +08:00
|
|
|
#include <spdlog/spdlog.h>
|
2024-06-18 10:04:50 +08:00
|
|
|
|
2024-10-08 14:34:52 +08:00
|
|
|
#define DEBUG
|
2024-09-30 13:34:05 +08:00
|
|
|
|
2024-07-25 15:46:49 +08:00
|
|
|
constexpr int CLIENT_WIDTH = 800;
|
|
|
|
constexpr int CLIENT_HEIGHT = 600;
|
2024-06-18 10:04:50 +08:00
|
|
|
|
2024-10-08 14:34:52 +08:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
spdlog::info("Current WorkDir Is: {}", argv[0]);
|
2024-09-30 13:34:05 +08:00
|
|
|
#ifdef DEBUG
|
2024-10-08 14:34:52 +08:00
|
|
|
argv[1] = R"(../img/ocean.mp4)";
|
2024-09-30 13:34:05 +08:00
|
|
|
#else
|
2024-10-08 14:34:52 +08:00
|
|
|
if (argc != 2) {
|
|
|
|
spdlog::error("Usage: mp filename ");
|
|
|
|
return 0;
|
|
|
|
}
|
2024-09-30 13:34:05 +08:00
|
|
|
#endif
|
2024-10-08 14:34:52 +08:00
|
|
|
spdlog::info("filename: {}", argv[1]);
|
|
|
|
std::shared_ptr<sf::RenderWindow> window =
|
|
|
|
std::make_shared<sf::RenderWindow>(
|
|
|
|
sf::VideoMode(CLIENT_WIDTH, CLIENT_HEIGHT), "mp");
|
|
|
|
MediaService mediaService(window, argv[1], CLIENT_WIDTH, CLIENT_HEIGHT);
|
|
|
|
bool running = true;
|
2024-06-18 10:04:50 +08:00
|
|
|
|
2024-10-08 14:34:52 +08:00
|
|
|
while (running) {
|
|
|
|
sf::Event event;
|
|
|
|
while (window->pollEvent(event)) {
|
|
|
|
if (event.type == sf::Event::Closed) {
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
if (event.type == sf::Event::KeyPressed) {
|
|
|
|
if (event.key.code == sf::Keyboard::Escape) {
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mediaService.Play();
|
|
|
|
}
|
|
|
|
return 0;
|
2024-06-18 10:04:50 +08:00
|
|
|
}
|