Quick and easy mp3 playing
-
- Posts: 2428
- Joined: Jul 19, 2006 19:17
- Location: Sunnyvale, CA
- Contact:
To answer the original question, the easiest way to play sound is through this .BI file that contains code modified from someone's FB MP3 player. The test program works if you have the called files. You can also pass URLs instead of file names. :-)
Imci.bi:
IMCITest.bas:
Imci.bi:
Code: Select all
' (C) 2007 i-TECH and Kristopher Windsor
#include once "windows.bi"
#include once "win/mmsystem.bi"
Const imci_standby = 0, imci_playing = 1
Dim Shared As Integer imci_mode
Dim Shared As Double imci_timer
Dim Shared As String imci_file
Declare Sub imci_stop
Sub imci_play (filename As String)
imci_stop 'stops current audio
If imci_mode = imci_standby Then
'open audio file
mciSendString("open """ + filename + """ type mpegvideo alias " + filename, NULL, 0, 0)
'start playing
mciSendString("play """ + filename + """ from 0", NULL, 0, 0)
'set timer when audio starts
imci_timer = Timer
'set mode
imci_file = filename
imci_mode = imci_playing
End If
End Sub
Sub imci_stop
If imci_mode = imci_playing Then
'close audio file
mciSendString("close """ + imci_file + """", NULL, 0, 0)
'set timer when audio stops
imci_timer = Timer
'set mode
imci_mode = imci_standby
End If
End Sub
Function imci_playtime as double
Return Timer - imci_timer
End Function
Code: Select all
#include "imci.bi"
imci_play "C:\music.mp3"
Sleep
imci_play "C:\music2.mp3" 'calls imci_stop to close previous audio file
Sleep
imci_stop 'must be called at the end of the program
Since I don't do win programming in FB (I use Delphi for that :)), it hasn't been a problem for me. However, a better solution is to wrap the defines in an #ifndef:maddogg6 wrote:I presume you mean - in addition to what I posted before that I needed to comment out..Code: Select all
'#define WAVE_FORMAT_1M08 &h00000001 '#define WAVE_FORMAT_1S08 &h00000002 '#define WAVE_FORMAT_1M16 &h00000004 '#define WAVE_FORMAT_1S16 &h00000008 '#define WAVE_FORMAT_2M08 &h00000010 '#define WAVE_FORMAT_2S08 &h00000020 '#define WAVE_FORMAT_2M16 &h00000040 '#define WAVE_FORMAT_2S16 &h00000080 '#define WAVE_FORMAT_4M08 &h00000100 '#define WAVE_FORMAT_4S08 &h00000200 '#define WAVE_FORMAT_4M16 &h00000400 '#define WAVE_FORMAT_4S16 &h00000800
Code: Select all
#ifndef __win_mmsystem_bi__
#define WAVE_FORMAT_1M08 &h00000001
#define WAVE_FORMAT_1S08 &h00000002
#define WAVE_FORMAT_1M16 &h00000004
#define WAVE_FORMAT_1S16 &h00000008
#define WAVE_FORMAT_2M08 &h00000010
#define WAVE_FORMAT_2S08 &h00000020
#define WAVE_FORMAT_2M16 &h00000040
#define WAVE_FORMAT_2S16 &h00000080
#define WAVE_FORMAT_4M08 &h00000100
#define WAVE_FORMAT_4S08 &h00000200
#define WAVE_FORMAT_4M16 &h00000400
#define WAVE_FORMAT_4S16 &h00000800
#endif
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
1) get fbsound 0.03badmrbox wrote:Couldn't sleep just yet so I tried it with fbc0.17. Same problems as with fbc0.16 but maybe that's not so strange. When I tried to run one of the test's from fb I got this error 'cannot find -lfbsoundwin'. What is that and why don't I have it?
http://alice-dsl.net/d.j.peters/fbsound/fbsound0.03.zip
2) extraxt it
for example to c:
3) open a console
c:
cd \fbsound0.03
makeall.bat
4) please report any error/warning message if any
5) cd tests
6) dir *.exe
it should be over 20 in the folder
Joshy
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact: