8. Audio/Video

Chapters

            8.1 Audio      

                        Audio is very important process in modern game. At present user have much choices for selecting audio format e.g. mp3, mp4, ogg, avi, flv, wma, mov, aac, wav, mpeg1, mpeg2, divx and xvid.

            How to manage all difference format of audio ? and Can cross to any device ? answer is use ARSA Framework write code 1 line can load audio on the fly.

            8.1.1 Play audio.

g_snd->Play( "win.wav" );// win.wav is sound file name, play one time.

            8.1.2 Audio Operation.

g_snd->Load( "win.wav" );// cache sound to memory

g_snd->Play( "win.wav", 0, true );// true is loop this sound

g_snd->Pause( "win.wav" );// pause

g_snd->Resume( "win.wav" );// resume from current position

g_snd->Stop( "win.wav" );// stop

g_snd->PauseAll( );// pause all sound in all channels

g_snd->PlayAll( ); // play all sound in all channels

g_snd->StopAll( );// stop all sound in all channels

if( !g_snd->isPlaying("win.wav") )

{

  // win.wav is not playing, if play with loop this function is not work

}

            8.2 Video

                        Same audio but use difference variable to handle

            8.2.1 Play Video.

// video handle variable

irr::arsa::CAVSceneNode* video = 0;

// allocate video handle, write at init

video = arsa_AddAV( );

// open video file

video->openFromFile( "combo.mpg" );

// play video

video->play();

            8.2.1 Video Operation.

// open video from filename

// "combo.mpg" = video filename

// true = video streaming ?

// irr::dimension2di(0,0) = video dimension

// 0,0 = original size

// -1,-1 = full screen

// 512, 512 = width and height are 512 pixels.

video->openFromFile("combo.mpg", true, irr::dimension2di(0,0));

// play video, true = play, false = pause

video->play( true );

// loop video

video->loop(true);

// stop video

video->stop();

// close video file

video->close();

// if true show video on screen, false not shown

video->show(true);

// if true close video after finished

video->setAutoClose(false);

// resize video texture

video->resize(irr::core::dimension2di(512,512))

// query video playback until end, true or false

 

video->isEnd();

// query video call play, true or false

video->isPlaying()

// query video is shown on screen, true or false

video->isShow();

// query video is auto close, true or false

video->isAutoClose();

// manual draw video

video->draw(true);

// get texture from video

video::ITexture* tex = video->getTexture();

// seek video by hour, minute and second

// hour = 0..24

// minute = 0..60

// second = 0..60

video->seek(0, 1, 5);

// seek by second

video->seek_sec(50);

// seek by percent 0..100

video->seek_percent(70);

Tags: