comparison music2/movie.cc @ 52:15a18fbe6f21

* Known bugs added to the README * Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author thib
date Sat, 18 Apr 2009 18:35:39 +0000
parents 223b71206888
children ddbcbd000206
comparison
equal deleted inserted replaced
51:cbb301016a4e 52:15a18fbe6f21
28 /* 28 /*
29 * movie.cc smpeg による動画再生 29 * movie.cc smpeg による動画再生
30 * 30 *
31 */ 31 */
32 32
33 #include<stdio.h> 33 #include <stdio.h>
34 #include"music.h" 34 #include "music.h"
35 #include<SDL.h> 35 #include <SDL.h>
36 #include<SDL_mixer.h> 36 #include <SDL_mixer.h>
37 #include<string.h> 37 #include <string.h>
38 #include<ctype.h> 38 #include <ctype.h>
39 #include<stdlib.h> 39 #include <stdlib.h>
40 #include"system/file.h" 40 #include "system/file.h"
41 #include"window/system.h" 41 #include "window/system.h"
42 42
43 #if USE_SMPEG 43 #if USE_SMPEG
44 #include<smpeg/smpeg.h> 44 #include <smpeg/smpeg.h>
45 45
46 static SMPEG* smpeg_handle = 0; 46 static SMPEG* smpeg_handle = 0;
47 const char* FindMovieFile(const char* path); 47 const char* FindMovieFile(const char* path);
48 void MuSys::PlayMovie(const char* path, int x1, int y1, int x2, int y2, int loop_count) { 48 void MuSys::PlayMovie(const char* path, int x1, int y1, int x2, int y2, int loop_count) {
49 if (!pcm_enable) return; 49 if (!pcm_enable) return;
50 FinalizeMusic(); 50 FinalizeMusic();
51 SMPEG_Info info; 51 SMPEG_Info info;
52 const char* find_path = FindMovieFile(path); 52 const char* find_path = FindMovieFile(path);
53 if (find_path == 0) return; 53 if (find_path == NULL) return;
54 smpeg_handle = SMPEG_new(find_path, &info, true); 54 smpeg_handle = SMPEG_new(find_path, &info, true);
55 //SMPEG_enableaudio(smpeg_handle, true); 55 //SMPEG_enableaudio(smpeg_handle, true);
56 //SMPEG_enablevideo(smpeg_handle, true); 56 //SMPEG_enablevideo(smpeg_handle, true);
57 SMPEG_enableaudio(smpeg_handle, true); 57 SMPEG_enableaudio(smpeg_handle, true);
58 SMPEG_enablevideo(smpeg_handle, true); 58 SMPEG_enablevideo(smpeg_handle, true);
59 SDL_Surface* surface = SDL_GetVideoSurface(); 59 SDL_Surface* surface = SDL_GetVideoSurface();
60 System::Main::DisableVideo(); 60 System::Main::DisableVideo();
61 SMPEG_setdisplay(smpeg_handle,surface,0,0); 61 SMPEG_setdisplay(smpeg_handle, surface, 0, 0);
62 // if (loop_c > 1) SMPEG_loop(smpeg_handle, true); 62 // if (loop_c > 1) SMPEG_loop(smpeg_handle, true);
63 //if (x1 != 0 || x2 != 0) SMPEG_setdisplayregion(smpeg_handle,x1, y1, x2-x1, y1-y2); 63 //if (x1 != 0 || x2 != 0) SMPEG_setdisplayregion(smpeg_handle,x1, y1, x2-x1, y1-y2);
64 SMPEG_play(smpeg_handle); 64 SMPEG_play(smpeg_handle);
65 #if 0 65 #if 0
66 while(SMPEG_status(smpeg_handle) != SMPEG_PLAYING) { 66 while(SMPEG_status(smpeg_handle) != SMPEG_PLAYING) {
67 SDL_Delay( 10 ); 67 SDL_Delay( 10 );
68 } 68 }
69 #endif 69 #endif
70 return; 70 return;
71 err:
72 StopMovie();
73 return;
74 } 71 }
72
75 const char* FindMovieFile(const char* path) { 73 const char* FindMovieFile(const char* path) {
76 ARCINFO* info = file_searcher.Find(FILESEARCH::MOV,path,"avi"); 74 ARCINFO* info = file_searcher.Find(FILESEARCH::MOV, path, "avi");
77 if (info == 0) 75 if (info == NULL)
78 info = file_searcher.Find(FILESEARCH::MOV,path,"mpg"); 76 info = file_searcher.Find(FILESEARCH::MOV,path,"mpg");
79 if (info == 0) return 0; 77 if (info == NULL) return NULL;
80 const char* file = info->Path(); 78 const char* file = info->Path();
81 delete info; 79 delete info;
82 return file; 80 return file;
83 } 81 }
84 82