CRI ADX  Last Updated: 2024-07-17 10:48 p
块播放

示例目录

/cri/pc/samples/criatomex/playback_block


示例描述

在播放作为块Cue的单一声音期间分支的示例程序。


由CRI Atom Craft创建块Cue。
详细信息请参照→ 播放块


在程序端,
使用::criAtomExPlayer_SetFirstBlockIndex函数,为Player指定第一个块索引,
使用::criAtomExPlayback_SetNextBlockIndex函数,为播放ID指定第二个或之后的块索引。
播放和控制中途有分支的块Cue的代码如下。
/* 创建Player */
player = criAtomExPlayer_Create(NULL, NULL, 0);
/* 设置块Cue */
player = criAtomExPlayer_SetCueName(acb, "block");
/* 选择第一个块 */
/* 开始播放 */
CriAtomExPlaybackId playback_id;
playback_id = criAtomExPlayer_Start(player);
:
/* 指定下一个块 */
if (status_of_something) {
} else {
}
void criAtomExPlayback_SetNextBlockIndex(CriAtomExPlaybackId id, CriAtomExBlockIndex index)
Set the index of the next block
void criAtomExPlayer_SetFirstBlockIndex(CriAtomExPlayerHn player, CriAtomExBlockIndex index)
Set the start block (by specifying a block index)
void criAtomExPlayer_SetCueName(CriAtomExPlayerHn player, CriAtomExAcbHn acb_hn, const CriChar8 *cue_name)
Set the sound data to play (specifying a Cue name)
CriAtomExPlaybackId criAtomExPlayer_Start(CriAtomExPlayerHn player)
Start the playback
CriAtomExPlayerHn criAtomExPlayer_Create(const CriAtomExPlayerConfig *config, void *work, CriSint32 work_size)
Create an AtomEx player
CriUint32 CriAtomExPlaybackId
Playback ID
Definition: cri_le_atom_ex.h:3722
如下面的代码所示,通过使用::criAtomExPlayer_SetBlockTransitionCallback函数, 可以在块切换时接收回调。
void main()
{
/* 注册过渡回调 */
app_obj->player, &user_transition_callback_func, app_obj);
}
void user_transition_callback_func(
{
printf("PlaybackId:%d, BlockIndex:%d\n", id, index);
}
CriSint32 CriAtomExBlockIndex
Block Index
Definition: cri_le_atom_ex.h:2304
void criAtomExPlayer_SetBlockTransitionCallback(CriAtomExPlayerHn player, CriAtomExPlayerBlockTransitionCbFunc func, void *obj)
Register the block transition callback function


示例使用的数据中AtomCraft项目的目录

/cri/tools/criatomex/examples/tutorial_data_for_runtime