MP3 Player September 07, 2009 07:22PM | Registered: 14 years ago Posts: 3 |
#include#include #include #include #include #include #include #include static void *xfb = NULL; static GXRModeObj *rmode = NULL; //--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- MP3Player_Init(); VIDEO_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); FILE *BGM = 0;//This will store an MP3 on the SD Card long lSize;//This will store the size of the FILE BGM char * buffer;//This is our buffer that will take the place of the external MP3 size_t result;//This is the size of the buffer bool mp3isready = false;//This keeps the music from trying to loop before the buffer is made void LoopTheMP3(); mp3isready = false;//Keeps LoopTheMP3() from working before the buffer is ready BGM = fopen("sd:/MUSIC/bgm.mp3", "rb"); fseek (BGM , 0 , SEEK_END); lSize = ftell (BGM); rewind (BGM);//Return to the beginning of the MP3 for good measure buffer = (char*) malloc (sizeof(char)*lSize);//Allocate memory to contain the whole file result = fread (buffer,1,lSize,BGM);//Copy the file into the buffer fclose(BGM);//Since we no longer need BGM, get rid of it MP3Player_PlayBuffer(buffer, lSize, NULL);//Play the buffer mp3isready = true;//Let LoopTheMP3() know it can start working free(buffer); void LoopTheMP3() { if(mp3isready && !MP3Player_IsPlaying()) MP3Player_PlayBuffer(buffer, lSize, NULL); } printf("MP3Player/n"); printf("First Attempt/n"); while(1) { WPAD_ScanPads(); u32 ButtonsDown = WPAD_ButtonsDown(0); if (ButtonsDown & WPAD_BUTTON_HOME) { exit(0); } } return 0; }
#--------------------------------------------------------------------------------- # Clear the implicit built in rules #--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC) endif include $(DEVKITPPC)/wii_rules #--------------------------------------------------------------------------------- # TARGET is the name of the output # BUILD is the directory where object files & intermediate files will be placed # SOURCES is a list of directories containing source code # INCLUDES is a list of directories containing extra header files #--------------------------------------------------------------------------------- TARGET := $(notdir $(CURDIR)) BUILD := build SOURCES := source DATA := data INCLUDES := include #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) CXXFLAGS = $(CFLAGS) LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- LIBS := -lwiiuse -lbte -logc -lm -lmad #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- LIBDIRS := #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional # rules for different file extensions #--------------------------------------------------------------------------------- ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- export OUTPUT := $(CURDIR)/$(TARGET) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) export DEPSDIR := $(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- # automatically build a list of object files for our project #--------------------------------------------------------------------------------- CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C #--------------------------------------------------------------------------------- ifeq ($(strip $(CPPFILES)),) export LD := $(CC) else export LD := $(CXX) endif export OFILES := $(addsuffix .o,$(BINFILES)) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(sFILES:.s=.o) $(SFILES:.S=.o) #--------------------------------------------------------------------------------- # build a list of include paths #--------------------------------------------------------------------------------- export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ -I$(CURDIR)/$(BUILD) \ -I$(LIBOGC_INC) #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ -L$(LIBOGC_LIB) export OUTPUT := $(CURDIR)/$(TARGET) .PHONY: $(BUILD) clean #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile #--------------------------------------------------------------------------------- clean: @echo clean ... @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol #--------------------------------------------------------------------------------- run: psoload $(TARGET).dol #--------------------------------------------------------------------------------- reload: psoload -r $(TARGET).dol #--------------------------------------------------------------------------------- else DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- $(OUTPUT).dol: $(OUTPUT).elf $(OUTPUT).elf: $(OFILES) #--------------------------------------------------------------------------------- # This rule links in binary data with the .jpg extension #--------------------------------------------------------------------------------- %.jpg.o : %.jpg #--------------------------------------------------------------------------------- @echo $(notdir $<) $(bin2o) -include $(DEPENDS) #--------------------------------------------------------------------------------- # This rule links in binary data #--------------------------------------------------------------------------------- %.bin.o : %.bin #--------------------------------------------------------------------------------- @echo $(notdir $<) @$(bin2o) %.mod.o : %.mod #--------------------------------------------------------------------------------- @echo $(notdir $<) @$(bin2o) -include $(DEPENDS) #--------------------------------------------------------------------------------- endif #---------------------------------------------------------------------------------
Re: MP3 Player September 07, 2009 08:35PM | Registered: 14 years ago Posts: 552 |
void LoopTheMP3() { if(mp3isready && !MP3Player_IsPlaying()) MP3Player_PlayBuffer(buffer, lSize, NULL); }
void LoopTheMP3();
LoopTheMP3();
Re: MP3 Player September 07, 2009 08:37PM | Registered: 15 years ago Posts: 703 |
Re: MP3 Player September 07, 2009 08:42PM | Registered: 14 years ago Posts: 552 |
Re: MP3 Player September 08, 2009 03:59AM | Registered: 14 years ago Posts: 3 |
Re: MP3 Player September 08, 2009 05:08AM | Registered: 14 years ago Posts: 552 |
Re: MP3 Player September 08, 2009 06:00AM | Registered: 14 years ago Posts: 3 |
Re: MP3 Player September 08, 2009 11:00PM | Admin Registered: 15 years ago Posts: 5,132 |
Yes, the only repeatedly reliable method (that I know of) to play external MP3s is here: [arikadosblog.blogspot.com]Quote
scanff
BTW the mp3 functions don't work all that well and I'd not recommend you start with trying to make an mp3 player on Wii.
Re: MP3 Player September 09, 2009 08:30PM | Registered: 15 years ago Posts: 703 |