Nov 18, 2019 12:43 PM
(This post was last modified: Nov 20, 2019 04:29 AM by Ryze.)
C++
basically i'm trying to add an mp3 file as a resource in visual studio and then play it but somehow i can't find any examples online!
how is this possible??
EDIT: i've got it working on playing .WAV files but it takes alot of memory 😑
resource.h:
function:
if anyone has a better solution to play embedded mp3 files not using 3rd party libraries, let me know
EDIT2: i think what i'll do is download the sound file and play it, it's easier and makes my binary lighter
basically i'm trying to add an mp3 file as a resource in visual studio and then play it but somehow i can't find any examples online!
how is this possible??
EDIT: i've got it working on playing .WAV files but it takes alot of memory 😑
resource.h:
PHP Code
<?php
#define IDR_WAVE1 104
function:
PHP Code
<?php
HINSTANCE h = ::GetModuleHandle(0);
HRSRC res = ::FindResource(h, MAKEINTRESOURCE(104), TEXT("WAVE"));
if (res == 0)
return;
HGLOBAL global = ::LoadResource(h, res);
if (global == 0)
return;
void* wav = ::LockResource(global);
if (wav == 0)
{
UnlockResource(global);
FreeResource(global);
return;
}
PlaySound(LPCWSTR(wav), NULL, SND_MEMORY | SND_ASYNC | SND_NODEFAULT);
UnlockResource(global);
FreeResource(global);
if anyone has a better solution to play embedded mp3 files not using 3rd party libraries, let me know
EDIT2: i think what i'll do is download the sound file and play it, it's easier and makes my binary lighter

