![]() |
AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
00001 // 00002 // 00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine 00004 // 00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk 00006 // 00007 // For updates, tutorials and more details check out www.appeasymobile.com 00008 // 00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin. 00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support 00011 // 00012 // 00013 00014 #if !defined(_CZ_VIDEO_H_) 00015 #define _CZ_VIDEO_H_ 00016 00017 #include "CzUtil.h" 00018 #include "CzXoml.h" 00019 #include "CzRect.h" 00020 #include "IzPlatformVideo.h" 00021 #include "CzEvents.h" 00022 00023 // 00024 // 00025 // 00026 // 00027 // CzVideo - A video file 00028 // 00029 // 00030 // 00031 // 00032 class CzVideo : public IzXomlResource 00033 { 00034 public: 00035 00036 enum eVideo_State 00037 { 00038 State_Invalid, 00039 State_Loaded, 00040 }; 00041 00042 // Proprties 00043 private: 00044 eVideo_State State; ///< State of video 00045 CzString Filename; ///< Name of video file 00046 int RepeatCount; ///< Total times to repeat play 00047 CzIRect Rect; ///< Position and size of video on screen 00048 eCzVideoCodec Codec; ///< Codec to use 00049 float Volume; ///< Volume of audio 00050 CzEventManager* EventsManager; ///< List of events that the video handles 00051 public: 00052 eVideo_State getState() const { return State; } 00053 CzString& getFilename() { return Filename; } 00054 void setRepeatCount(int count) { RepeatCount = count; } 00055 int getRepeatCount() const { return RepeatCount; } 00056 CzIRect getRect() const { return Rect; } 00057 void setRect(int x, int y, int w, int h) { Rect.x = x; Rect.y = y; Rect.w = w; Rect.h = h; } 00058 void setRect(CzIRect &rect) { Rect = rect; } 00059 eCzVideoCodec getCodec() const { return Codec; } 00060 void setVolume(float volume) { Volume = volume; } 00061 float getVolume() const { return Volume; } 00062 // Properties end 00063 00064 protected: 00065 char* VideoData; ///< Raw video data 00066 uint32 VideoDataLen; ///< Length of raw video data 00067 CzFile* File; ///< File object (if video if file based) 00068 public: 00069 00070 CzVideo() : IzXomlResource(), File(NULL), State(State_Invalid), VideoData(NULL), VideoDataLen(0), EventsManager(NULL), Rect(0, 0, 0, 0), Codec(Video_Codec_Mpeg4), Volume(1.0f) 00071 { 00072 setClassType("video"); 00073 EventsManager = new CzEventManager(); 00074 } 00075 virtual ~CzVideo(); 00076 00077 bool Init(const char* filename, bool preload, bool blocking, eCzVideoCodec codec); 00078 bool Init(char* video_data, uint32 video_data_len, eCzVideoCodec codec); 00079 bool Play(); 00080 bool Load(bool blocking = true); // Force load the video file 00081 00082 // Implementation of IzXomlResource interface 00083 int LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node); 00084 00085 // Event handlers 00086 virtual void ProcessEventActions(unsigned int event_name); 00087 virtual void NotifyStopped(); 00088 00089 // Internal 00090 void FinishLoad(); // Called back when aysnc loading is completed 00091 }; 00092 // 00093 // CzVideoCreator - Creates an instance of a video object 00094 // 00095 class CzVideoCreator : public IzXomlClassCreator 00096 { 00097 public: 00098 CzVideoCreator() 00099 { 00100 setClassName("video"); 00101 } 00102 IzXomlResource* CreateInstance(IzXomlResource* parent) { return new CzVideo(); } 00103 }; 00104 00105 00106 00107 00108 #endif // _CZ_VIDEO_H_