0
0

I’m trying to program my own MP3 player in MFC (Visual C++ 6.0), and I am having trouble playing the song.

The problem is that I can I THINK load the song correctly w/o trouble, but I can’t have the song play. Here’s the code I use:

[code:2pkn54zc]
void CMMPDlg::OnOpen()
{
//LoadFile((LPCTSTR) myCString);

// TODO: Add your command handler code here
file.m_ofn.lStructSize = sizeof(file.m_ofn);
file.m_ofn.lpstrDefExt = "mp3";
file.m_ofn.hwndOwner   = NULL;
file.m_ofn.lpstrTitle  = "Open A Media File";

if(file.DoModal() == IDOK){
    if(FMUSIC_SetMasterVolume(music, 256) == TRUE){
        AfxMessageBox("Master volume set to 256!");
    }
    else{
        AfxMessageBox("Unable to set master volume!");
    }

    AfxMessageBox(FMUSIC_GetMasterVolume(music));

    music = FMUSIC_LoadSongEx((LPCTSTR)file.GetFileName(), 0, 0, FSOUND_LOOP_NORMAL, NULL, NULL); //((LPCTSTR)file.GetFileName());
    FMUSIC_PlaySong(music);
}

}
[/code:2pkn54zc]

OnOpen is the function for a button

And here’s the CFileDialog constructor & FMUSIC_MODULE:

[code:2pkn54zc]
// MP3 Stream global
extern FMUSIC_MODULE *music = NULL;

// CFileDialog constructor
CFileDialog file(TRUE, "mp3", NULL, OFN_HIDEREADONLY, "MP3 Files (.mp3)|.mp3||", NULL);
[/code:2pkn54zc]

  • You must to post comments
0
0

[quote="brett":2y2getql]FMUSIC is for sequenced formats like mod/s3m/xm/it/midi and fsb.
FSOUND_Stream is what you are after for the mp3 format.[/quote:2y2getql]
Ok, thank you.

I’ll change it to FSOUND_Stream to do it.

  • You must to post comments
0
0

Ok, I’ve ran into a little problem:

I cannot seem to create a FSOUND_STREAM_CREATE callback. Here’s the code I use for it:
[code:2puxxneb]
extern FSOUND_STREAMCALLBACK StreamCall(FSOUND_STREAM *stream, void *buffer, int len, int param){

return 0;

}
[/code:2puxxneb]

And here’s where I TRY to use it:
[code:2puxxneb]
// TODO: Add extra initialization here
if(FSOUND_Init(44100, 100, FSOUND_INIT_USEDEFAULTMIDISYNTH) == FALSE){
sprintf(err, "Error initializing FMOD! Closing...");
AfxMessageBox(err);

    Free(music, sound);
}

if(FSOUND_Stream_Create(StreamCall, 1024, FSOUND_LOOP_NORMAL, 44100, 0) == NULL){
    sprintf(err, "Unable to create stream!");
    AfxMessageBox(err);
}

[/code:2puxxneb]

Here’s the errors I get:

[quote:2puxxneb]
C:\Program Files\Microsoft Visual Studio\MyProjects\MMP\MMPDlg.cpp(132) : error C2664: ‘FSOUND_Stream_Create’ : cannot convert parameter 1 from ‘signed char (__stdcall *(struct FSOUND_STREAM *,void *,int,int))(struct FSOUND_STREAM *,void *,int,int)’
to ‘signed char (__stdcall *)(struct FSOUND_STREAM *,void *,int,int)’
None of the functions with this name in scope match the target type
[/quote:2puxxneb]

I’ve tried a few things, but none seem to work. Does anyone have any idea on why this is happening (and hopefully a way to fix it)?

  • You must to post comments
0
0

[quote="brett":20ungiv7]you should probably remove the word extern[/quote:20ungiv7]
Na, that’s not it. I got it fixed none-the-less.

I think it deals w/ calling trying to set it in channel 0. If I do it to channel 1, it works perfect. Thanks though.

  • You must to post comments
0
0

[quote="brett":3g8kgqwn]what has channging a 0 to 1 got to do with

[quote:3g8kgqwn]
C:\Program Files\Microsoft Visual Studio\MyProjects\MMP\MMPDlg.cpp(132) : error C2664: ‘FSOUND_Stream_Create’ : cannot convert parameter 1 from ‘signed char (__stdcall *(struct FSOUND_STREAM *,void *,int,int))(struct FSOUND_STREAM *,void *,int,int)’
to ‘signed char (__stdcall *)(struct FSOUND_STREAM *,void *,int,int)’
None of the functions with this name in scope match the target type
[/quote:3g8kgqwn]

???

Are you talking about a completely different function now? If you mean tthe channel id in fsound_stream_play you should be using FSOUND_FREE.[/quote:3g8kgqwn]
No no no, I’ve been using that. Come to think about it, it’s been about more than 24 hrs since I’ve fixed it, so I don’t know why it didn’t work.

  • You must to post comments
0
0

[quote="brett":1agykqpb]oh and i see you used FSOUND_STREAMCALLBACK as the return value, so that would be the real error. that is a pointer to a function, the stream callback requires a return value of ‘int’, and stdcall so F_CALLBACKAPI should have been specified as well.
Of course this is easily seen in the stream 2 example and the documentation.[/quote:1agykqpb]
And of course there’s so many streams laying around in the docs that it was kinda hard for me to actually realize this.

Anyways…….I haven’t even use the StreamCall function I think and it’s running perfectly.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.