Mercurial > hg > easaier-soundaccess
diff data/fileio/VideoFileReader.cpp @ 167:2ac52ea3c1c4
video mouse events are in SDL now.
The code is really better now, but there is a display bug when you zoom in, zoom out
author | benoitrigolleau |
---|---|
date | Fri, 16 Nov 2007 15:18:44 +0000 |
parents | c946c19e6329 |
children | be6d31baecb9 |
line wrap: on
line diff
--- a/data/fileio/VideoFileReader.cpp Fri Nov 16 13:17:55 2007 +0000 +++ b/data/fileio/VideoFileReader.cpp Fri Nov 16 15:18:44 2007 +0000 @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <cassert> #include <iostream> @@ -32,10 +33,10 @@ #ifdef WIN32 #include <Windows.h> #endif -extern float zoomFivan; long long countFreq; int Videow=320; int Videoh=240; +float zoomFivan=1; VideoFileReader::VideoFileReader(QString path, bool showProgress, CacheMode mode) : CodedAudioFileReader(mode), m_path(path) @@ -47,6 +48,7 @@ m_bitrateNum = 0; m_bitrateDenom = 0; m_cancelled = false; + m_zoomfactor = 1; struct stat stat; if (::stat(path.toLocal8Bit().data(), &stat) == -1 || stat.st_size == 0) { @@ -195,17 +197,24 @@ SDL_ffmpegGetVideoSize(file, &w, &h); MainWindow * MWins=MainWindow::instance(); - MWins->setSDLInitSize(w,h); + SDL_Init(SDL_INIT_VIDEO); - Videow=w=320*zoomFivan; - Videoh=h=240*zoomFivan; + Videow=w;//=320*m_zoomfactor; + Videoh=h;//=240*m_zoomfactor; + + //TODO update the size according to the component size + // this will not work if video size is bigger than window size. + m_width =w; + m_height =h; + + MWins->setSDLInitSize(w,h); // Open the Video device screen = SDL_SetVideoMode(w, h, 0, SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); //SDL_WM_SetCaption("EASAIER Video Player", "EASAIER Video Player"); if(!screen) { - printf("Couldn't open video: %s\n", SDL_GetError()); + fprintf(stderr, "Couldn't open video: %s\n", SDL_GetError()); return false; } return true; @@ -216,6 +225,61 @@ return ((VideoFileReader *)t)->videoPlay(); } +void VideoFileReader::processEvents() +{ + SDL_Event event; + + while (SDL_PollEvent(&event)) + { + float signe = 1; + switch (event.type) + { + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + switch(event.button.button){ + case SDL_BUTTON_LEFT : + break; + case SDL_BUTTON_MIDDLE: + break; + case SDL_BUTTON_RIGHT: + break; + default: + break; + } + break; + case SDL_MOUSEBUTTONUP: + + switch(event.button.button){ + case SDL_BUTTON_LEFT : + break; + case SDL_BUTTON_MIDDLE: + break; + case SDL_BUTTON_RIGHT: + break; + case SDL_BUTTON_WHEELDOWN: + signe = -1; + case SDL_BUTTON_WHEELUP: + float f,f2; + f = m_zoomfactor + signe * 0.1; + f2 = f; + if((int)(m_width*f+0.5)%4){ + f = (m_width*f - (int)(m_width*f+0.5)%4)/m_width; + } + m_zoomfactor=f; + + break; + default: + break; + } + break; + + default: + break; + } + } +} + int VideoFileReader::videoPlay() { @@ -243,12 +307,24 @@ film->vs[film->videoStream]->lastTimeStamp=0; while( film->videoThreadActive ) { - if (!(w==(int)(320*zoomFivan))){ - w=320*zoomFivan; - h=240*zoomFivan; - // Open the Video device - screen = SDL_SetVideoMode(w, h, 0, SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); + if (!(w==(int)(Videow*m_zoomfactor))){ + w=Videow*m_zoomfactor; + h=Videoh*m_zoomfactor; + if (w<80 || h<60){ + w=80; + h=60; + m_zoomfactor = 80.0/Videow; + } + // Open the Video device + zoomFivan = m_zoomfactor; + screen = SDL_SetVideoMode(w, h, 0, SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); + MWins->setSDLInitSize(w,h); + m_width =w; + m_height =h; + } + // calls process events function, to take in account the user input + processEvents(); if (MWins->isAudioPlaying()) { if ((SDL_ffmpegGetState(film))||((long)(abs((long)(film->audioTime - (int64_t)(MWins->Get_CurAudioTime()))))>=1000))