CRI ADX  Last Updated: 2024-07-17 10:48 p
播放开始同步

示例目录

/cri/pc/samples/criatomex/pause_playback


示例描述

如果想要多个流播放的开始同步,请使用::criAtomExPlayer_Prepare函数。
使用::criAtomExPlayer_Prepare函数会进行可以立即发声之前的播放开始所需的准备工作。


可以通过播放ID的状态变为::CRIATOMEXPLAYBACK_STATUS_PLAYING来确认播放准备完成。
(无法开始播放的状态是::CRIATOMEXPLAYBACK_STATUS_PREP。)
播放ID可以作为::criAtomExPlayer_Prepare函数的返回值获取播放ID,把播放ID保存在应用程序端。


播放准备完成后,要实际开始播放,请使用::criAtomExPlayback_Pause函数对播放ID取消暂停。
CriAtomExPlayeBackId playback_id; /* 播放ID */
/* 开始播放准备 */
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_THUNDER1);
playback_id = criAtomExPlayer_Prepare(player);
for(;;) {
CriAtomExPlaybackStatus playback_status;
sleep(1);
playback_status = criAtomExPlayback_GetStatus(playback_id);
if (playback_status == CRIATOMEXPLAYBACK_STATUS_PLAYING) {
/* 播放准备完成 */
break;
}
}
/* 开始发声(取消播放ID的暂停) */
criAtomExPlayback_Pause(playback_id, CRI_FALSE);
void criAtomEx_ExecuteMain(void)
Execute the server processing
CriAtomExPlaybackStatus criAtomExPlayback_GetStatus(CriAtomExPlaybackId id)
Get the playback status
void criAtomExPlayback_Pause(CriAtomExPlaybackId id, CriBool sw)
Pause/resume the sound
enum CriAtomExPlaybackStatusTag CriAtomExPlaybackStatus
Playback status
@ CRIATOMEXPLAYBACK_STATUS_PLAYING
Definition: cri_le_atom_ex.h:4180
CriAtomExPlayerObj * CriAtomExPlayerHn
Player handle
Definition: cri_le_atom_ex.h:3622
CriAtomExPlaybackId criAtomExPlayer_Prepare(CriAtomExPlayerHn player)
Prepare the playback
void criAtomExPlayer_SetCueId(CriAtomExPlayerHn player, CriAtomExAcbHn acb_hn, CriAtomExCueId id)
Set the sound data to play (specifying a Cue ID)


如果要同步播放开始时间,请用一个Player对多个声音做好播放准备, 取消Player暂停,将一齐开始发声。
可通过::CriAtomExPlayerHn的状态确认播放准备是否完成。
/* 开始播放准备 */
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_THUNDER1);
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_THUNDER2);
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_THUNDER3);
for(;;) {
CriAtomExPlayerStatus player_status;
sleep(1);
player_status = criAtomExPlayer_GetStatus(player);
if (player_status == CRIATOMEXPLAYER_STATUS_PLAYING) {
/* 播放准备完成 */
break;
}
}
/* 一齐开始发声(开始时间同步) */
criAtomExPlayer_Pause(player, CRI_FALSE);
CriAtomExPlayerStatus criAtomExPlayer_GetStatus(CriAtomExPlayerHn player)
Get the player status
enum CriAtomExPlayerStatusTag CriAtomExPlayerStatus
Player status
void criAtomExPlayer_Pause(CriAtomExPlayerHn player, CriBool sw)
Pause/resume
@ CRIATOMEXPLAYER_STATUS_PLAYING
Definition: cri_le_atom_ex.h:3669