使用只能指针代替裸指针
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include <mediaService.h>
|
||||
#include <memory>
|
||||
#include <videoService.h>
|
||||
|
||||
MediaService::MediaService(const std::string& filename, int width, int height){
|
||||
auto type = UtilTool::CheckFileType(filename);
|
||||
type = UtilTool::CheckFileType(filename);
|
||||
client_width = width;
|
||||
client_height = height;
|
||||
float scale = .0f;
|
||||
@@ -9,14 +11,34 @@ MediaService::MediaService(const std::string& filename, int width, int height){
|
||||
{
|
||||
case MediaType::IMAGE:
|
||||
imageService = new ImageService(filename);
|
||||
texture = &imageService->GetTexture();
|
||||
sprite = new sf::Sprite();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
src/videoService.cc
Normal file
1
src/videoService.cc
Normal file
@@ -0,0 +1 @@
|
||||
#include "videoService.h"
|
||||
Reference in New Issue
Block a user