#include <mediaService.h>
#include <memory>
#include <videoService.h>

MediaService::MediaService(const std::string& filename, int width, int height){
    type = UtilTool::CheckFileType(filename);
    client_width = width;
    client_height = height;
    float scale = .0f;
    switch (type)
    {
    case MediaType::IMAGE:
        imageService = new ImageService(filename);
        texture = imageService->GetTexture();
        sprite = std::make_shared<sf::Sprite>();
        sprite->setTexture(*texture);
        scale = imageService->GetScale(client_width, client_height);
        sprite->setScale(scale, scale);
        break;
	case MediaType::VIDEO:
		break;
    
    default:
        break;
    }
}

void MediaService::SetWindow(std::shared_ptr<sf::RenderWindow> window){
    this->window = window;
}

void MediaService::Play(){
    switch (type)
    {
    case MediaType::IMAGE:
        window->clear();
        window->draw(*sprite);
        window->display();
        break;
    
    default:
        break;
    }
}
