LFile::GetExtensionAudio
#include "ltwrappr.h"
virtual L_INT LFile::GetExtensionAudio(pExtensionList, nIndex, ppBuffer, puSize)
pEXTENSIONLIST pExtensionList; |
/* pointer to a structure */ |
L_INT nIndex; |
/* audio stream index */ |
L_CHAR * * ppBuffer; |
/* pointer to a pointer */ |
L_UINT *puSize; |
/* pointer to a variable to be updated */ |
Gets the embedded audio data from the specified extension list.
Parameter |
Description |
pExtensionList |
Pointer to the EXTENSIONLIST structure that contains the audio data to get. |
nIndex |
Index of the audio stream to retrieve. The extensions may have more than one audio stream. This index is 0-based. Therefore, the first stream is stream 0, the second stream is stream 1, etc. To retrieve all the audio streams, retrieve the streams one by one until an error is returned. |
ppBuffer |
Pointer to be updated with a pointer to the retrieved audio data. This pointer will point into the pExtensionList. Therefore, this pointer will be valid as long as pExtensionList is valid. The memory will be freed when LFile::FreeExtensions is called, so do not try to free this memory. |
puSize |
Pointer to a variable to be updated with the size of the audio data. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
The audio data is stored inside extensions in the WAVE format. The audio data can be played directly from memory, or the data can be written to a disk file and played from the disk. When writing the audio data to a disk file, give the file a .WAV extension.
Required DLLs and Libraries
LTFIL For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
LFile::ReadFileExtensions, LFile::LoadExtensionStamp, LFile::FreeExtensions, Class Members |
Topics: |
Raster Image Functions: Getting and Setting File Information |
|
|
|
Example
#include <stdio.h>
L_VOID TestFunction(L_TCHAR * pszFile, L_TCHAR * pszAudioFile)
{
LFile File;
pEXTENSIONLIST pExtensionList;
File.SetFileName(pszFile);
if (File.ReadFileExtensions(&pExtensionList) != SUCCESS)
{
MessageBox(NULL, TEXT("Error getting extensions!"), TEXT("Testing"), MB_OK);
return;
}
if (pExtensionList->uFlags & EXTENSION_AUDIO)
{
L_CHAR * pData;
L_UINT uSize;
if (File.GetExtensionAudio (pExtensionList, 0, &pData, &uSize)
!= SUCCESS)
MessageBox(NULL, TEXT("Error getting the audio data!"),
TEXT("Testing"), MB_OK);
else
{
FILE * fd;
#ifdef UNICODE
fd = _wfopen(pszAudioFile, TEXT("wb")); // pszAudioFile: .wav file
#else
fd = fopen(pszAudioFile, "wb"); // pszAudioFile: .wav file
#endif
if (fd)
{
fwrite(pData, uSize, 1, fd);
fclose(fd);
}
}
}
File.FreeExtensions(pExtensionList);
}