Example #1
0
int  __stdcall  CallbackFunc(void* instance, void *user_data, TCallbackMessage message, unsigned int param1, unsigned int param2)
{
	ZPlay *myinstance = (ZPlay*) instance;

	switch(message)
	{
		case MsgStreamNeedMoreDataAsync:
		{
			FILE *in = (FILE*) user_data;

			// read data into memory buffer
			int nRead = fread(buf, 1, BUFFER_SIZE, in);

			if(nRead == 0)
			{
				// there is no data in file, end of file
				// push null buffer to indicate that there will be no more data
				myinstance->PushDataToStream(0, 0);	
			}
			else
			{
				// add new data to stream
				myinstance->PushDataToStream(buf, nRead);	
			}
		}
		return 0;
	}

	return 0;
}
int  __stdcall  myCallbackFunc(void* instance, void *user_data, TCallbackMessage message, unsigned int param1, unsigned int param2)
{
	ZPlay *myplayer = (ZPlay*) instance;

	switch(message)
	{
		case MsgStreamNeedMoreData: // stream needs more data
		{
			FILE *in = (FILE*) user_data; // this parameter is set by SetCallbackFunc

			// read next chunk of data from file into memory buffer
			char buffer[10000];
			unsigned int read = fread(buffer, 1, 10000, in);

			// push this memory buffer into stream
			myplayer->PushDataToStream(buffer, read);
		}
		return 0;	
	}

	return 0;
}