2024-09-30 13:34:05 +08:00
|
|
|
#include <SFML/Graphics/RenderWindow.hpp>
|
2024-07-25 15:46:49 +08:00
|
|
|
#include <cstdio>
|
2024-06-18 10:04:50 +08:00
|
|
|
#include <SFML/System.hpp>
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <SFML/Window.hpp>
|
2024-06-18 11:16:30 +08:00
|
|
|
#include <spdlog/spdlog.h>
|
2024-07-25 15:46:49 +08:00
|
|
|
#include "UtilTool.h"
|
2024-09-09 13:20:59 +08:00
|
|
|
#include "mediaService.h"
|
2024-10-08 14:37:53 +08:00
|
|
|
#include "SFML/Window/VideoMode.hpp"
|
2024-06-18 10:04:50 +08:00
|
|
|
|
2024-10-08 14:37:53 +08:00
|
|
|
#define DEBUG
|
|
|
|
using namespace std::string_view_literals;
|
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-07-25 15:46:49 +08:00
|
|
|
|
|
|
|
int main(int argc, char** argv){
|
2024-10-08 14:37:53 +08:00
|
|
|
auto filename = R"(C:/document/project/mp-sfml/img/ocean.mp4)"sv;
|
2024-09-30 13:34:05 +08:00
|
|
|
spdlog::info("Current WorkDir Is: {}",argv[0]);
|
|
|
|
#ifdef DEBUG
|
|
|
|
#else
|
2024-10-08 14:37:53 +08:00
|
|
|
filename = argv[1];
|
2024-07-25 15:46:49 +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:37:53 +08:00
|
|
|
spdlog::info("filename: {}", filename);
|
|
|
|
MediaService mediaService(filename.data(), CLIENT_WIDTH, CLIENT_HEIGHT);
|
2024-09-30 13:34:05 +08:00
|
|
|
std::shared_ptr<sf::RenderWindow> window = std::make_shared<sf::RenderWindow>(sf::VideoMode(CLIENT_WIDTH, CLIENT_HEIGHT), "mp");
|
|
|
|
mediaService.SetWindow(window);
|
2024-06-18 10:04:50 +08:00
|
|
|
bool running = true;
|
|
|
|
while(running){
|
|
|
|
sf::Event event;
|
2024-09-30 13:34:05 +08:00
|
|
|
while(window->pollEvent(event)){
|
2024-06-18 10:04:50 +08:00
|
|
|
if(event.type == sf::Event::Closed){
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
if(event.type == sf::Event::KeyPressed){
|
|
|
|
if(event.key.code == sf::Keyboard::Escape){
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-09-30 13:34:05 +08:00
|
|
|
mediaService.Play();
|
2024-06-18 10:04:50 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|