這是使用蓋莫游戲引擎播放視頻的例子
當前解碼器為ffmpeg.
以后還會使用dxshow解碼
播放代碼如下:
1 #include <stdio.h>
2 #include <GEngine/Gaimo.hpp>
3
4 using namespace core;
5
6 bool state = 0;
7 //! 視頻播放完成后的處理工作
8 inline void IsVideoEnded(){state = 1;}
9
10 using namespace core;
11 int main()
12 {
13 RefPtr<Device> device = InitDevice("視頻播放");
14 //! 獲取視頻播放器指針
15 RefPtr<VideoPlayer> player = device->GetVideoPlayer();
16 //! 不處理音頻的話那么視頻將會是無聲的O(∩_∩)O~
17 core::RefPtr<core::AudioDevice> audiodevice = device->GetAudioDevice();
18 uint16 number = audiodevice->GetAudioDeviceNumber();
19 engine_string audiodeviceinde = audiodevice->GetDeviceByIndex(1);
20 std::cout<<audiodevice->GetDeviceByIndex(1)<<std::endl;
21 std::cout<<audiodevice->GetDefaultDeviceName()<<std::endl;
22 std::cout<<"初始化音頻設備"<<audiodevice->Init(audiodeviceinde,4,0)<<std::endl;
23 player->isstoped.connect( sigc::ptr_fun(&IsVideoEnded));
24 player->Play("..\\video//1.Mp4",Rectf(-1,-1,2,2));
25 player->SetVolume(1.0f);
26
27 BEGIN_LOOP(device)
28 player->Update();
29 BREAK_LOOP(state,1);
30 END_LOOP(device)
31 return 0;
32 }
33
可以看出當前代碼使用sigc++作為插槽系統當播放結束的時候程序自動退出(當然可選sigslot)O(∩_∩)O~
截圖如下: