48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#include <SFML/Graphics/RenderWindow.hpp>
|
|
#include <cstdio>
|
|
#include <SFML/System.hpp>
|
|
#include <SFML/Graphics.hpp>
|
|
#include <SFML/Window.hpp>
|
|
#include <spdlog/spdlog.h>
|
|
#include "UtilTool.h"
|
|
#include "mediaService.h"
|
|
|
|
#define DEBUG
|
|
|
|
constexpr int CLIENT_WIDTH = 800;
|
|
constexpr int CLIENT_HEIGHT = 600;
|
|
|
|
|
|
int main(int argc, char** argv){
|
|
spdlog::info("Current WorkDir Is: {}",argv[0]);
|
|
#ifdef DEBUG
|
|
argv[1] = R"(../img/ocean.jpg)";
|
|
#else
|
|
if(argc != 2){
|
|
spdlog::error("Usage: mp filename ");
|
|
return 0;
|
|
}
|
|
#endif
|
|
spdlog::info("filename: {}", argv[1]);
|
|
MediaService mediaService(argv[1], CLIENT_WIDTH, CLIENT_HEIGHT);
|
|
std::shared_ptr<sf::RenderWindow> window = std::make_shared<sf::RenderWindow>(sf::VideoMode(CLIENT_WIDTH, CLIENT_HEIGHT), "mp");
|
|
mediaService.SetWindow(window);
|
|
bool running = true;
|
|
|
|
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;
|
|
}
|