Set callback function.
__stdcall __declspec(dllimport) int zplay_SetCallbackFunc(ZPLAY_HANDLE handle, TCallbackFunc pCallbackFunc, TCallbackMessage nMessages, void * user_data);
Parameters |
Description |
ZPLAY_HANDLE handle |
ZPLAY handle. Get this handle with zplay_CreateZPlay. |
TCallbackFunc pCallbackFunc |
Pointer to callback function. Set this value to NULL to disable callback mechanism. |
TCallbackMessage nMessages |
Specify messages you need to receive with callback function. This parameter can be combination of multiple callback messages. |
void * user_data |
User data. This value will be passed to pCallbackFunc as parameter. |
Return Values |
Description |
1 |
All OK. |
0 |
Error. To get error message read here. |
All callback messages are sent from decoding thread.
There are 2 types of callback messages, blocking (sync) and not blocking (async).
Blocking message will block decoding thread until callback function returns. Non blocking mesage will not block decoding thread.
Warning: callback function must have __stdcall calling convention.
// my callback function int __stdcall CallbackFunc(void* instance, void *user_data, TCallbackMessage message, unsigned int param1, unsigned int param2) { ZPlay *instance = (ZPlay*) instance; switch(message) { case MsgNextSongAsync: { printf("MsgNextSongAsync %u %u", param1, param2); } return 0; case MsgNextSong: { printf("MsgNextSong %u %u", param1, param2);; } return 0; } return 0; } ... // set callback function to receive MsgNextSongAsync and MsgNextSong message instance->SetCallbackFunc(CallbackFunc, (TCallbackMessage) (MsgNextSongAsync + MsgNextSong), 0);
// my callback function int __stdcall CallbackFunc(void* instance, void *user_data, TCallbackMessage message, unsigned int param1, unsigned int param2) { ZPlay *instance = (ZPlay*) instance; switch(message) { case MsgNextSongAsync: { printf("MsgNextSongAsync %u %u", param1, param2); } return 0; case MsgNextSong: { printf("MsgNextSong %u %u", param1, param2);; } return 0; } return 0; } ... // set callback function to receive MsgNextSongAsync and MsgNextSong message zplay_SetCallbackFunc(instance, CallbackFunc, (TCallbackMessage) (MsgNextSongAsync + MsgNextSong), 0);
Copyright (c) 2010. Zoran Cindori - All rights reserved.
Web: http://libzplay.sourceforge.net/ Email: zcindori@inet.hr |