<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>How to Play Sound and Video Files</title>
<description> I apologize if this has already been posted and replied to (if it has, I couldn&amp;#039;t find it), but how would one go about playing .mp3&amp;#039;s, .wav&amp;#039;s, .avi&amp;#039;s, .mov, etc... using homebrew? Also, rather than making a new thread, I have another (rather random) question. Is declaring
char characterVariable[20];
the same thing as calling
char characterVariable;
characterVariable=malloc(20*sizeof(char));
I&amp;#039;m a complete noob when it comes to pointers and memory management, so this probably isn&amp;#039;t right.</description><link>http://forum.wiibrew.org/read.php?11,20240,20240#msg-20240</link><lastBuildDate>Sat, 06 Jun 2026 00:19:23 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,22268#msg-22268</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,22268#msg-22268</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Nicholas_Roge</strong><br />No, no. By no means do I want a simple fix. I plan on majoring in Computer Science, so as much knowledge before hand would be nice. And I&#039;m gonna take a look at mplayer&#039;s source. That still doesn&#039;t fix my previous problem with the sound though.</div></blockquote><br />Why not try the SDL port. The video system uses GX and ogg works great. I&#039;ve not tried mp3 with it yet.<br /><br />There are thousands of tutorials around the web for SDL and I&#039;m sure a few projects that use SDL as video players. It would be easy to port a SDL video player to Wii.<br /><br />[<a href="http://code.google.com/p/sdl-wii/" rel="nofollow">code.google.com</a>]]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Fri, 26 Jun 2009 02:06:33 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,22233#msg-22233</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,22233#msg-22233</link><description><![CDATA[ No, no. By no means do I want a simple fix. I plan on majoring in Computer Science, so as much knowledge before hand would be nice. And I&#039;m gonna take a look at mplayer&#039;s source. That still doesn&#039;t fix my previous problem with the sound though.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Thu, 25 Jun 2009 23:45:20 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,22175#msg-22175</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,22175#msg-22175</link><description><![CDATA[ I meant for a *very* short video. Like, animated GIF level. Though even a thousand-frame video could be made to work that way if the resolution is small enough or you load textures from SD.<br /><br />My guess is that Nicholas_Roge doesn&#039;t have the experience to be able to adapt mplayer&#039;s source and just wants a simple AVI_PlayVideo() function (which doesn&#039;t exist, so don&#039;t look for it). Given that, the mplayer option is not "easy" enough to be a viable option, though I agree that it&#039;s the best approach if you *do* have the expertise.]]></description>
<dc:creator>ulti</dc:creator>
<category>Coding</category><pubDate>Thu, 25 Jun 2009 18:46:11 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,21956#msg-21956</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,21956#msg-21956</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>ulti</strong><br />@Nicholas_Roge:<br /><br />As jsmaster said, "GX" refers to the graphics library. The functions that start with GX_ control the 3d hardware and let you do things like display polygons. Normally this is what you want to use when you&#039;re making a game because the 3d hardware is specifically designed to do these kind of things, and is very fast.<br /><br />However, that&#039;s not the only way to get things to show up on screen. The way display works on the Wii, you have a block of memory called your "framebuffer" that represents what actually gets displayed. GX works by taking in abstract constructs like polygons, figuring out how to draw them, then drawing the result to the framebuffer. You&#039;re also allowed to write directly to the framebuffer (it&#039;s just ordinary memory after all). This is slower because you don&#039;t get the benefit of hardware acceleration and more complicated because the pixels are stored in a funny format, but for certain types of applications it&#039;s a valid option. Video is one of them, mainly because it doesn&#039;t benefit at all from the 3d hardware but also because you&#039;re already working with the image on a pixel-by-pixel basis so the conversion to the funny format isn&#039;t as big a drawback.<br /><br />If you just want to display a very simple video then the easiest way to show it might be to just store each frame as a texture and quickly cycle through them. It won&#039;t be compressed and you can&#039;t just load an .avi file and expect it to work, but it&#039;s the easiest option using the available tools. You would want to use GX for that.</div></blockquote><br />Of course that would mean you would need thousands of textures just for a short video. I would think the best (and easiest) solution would be to copy some of mplayer&#039;s source (if that is allowed with the licensing).]]></description>
<dc:creator>jsmaster</dc:creator>
<category>Coding</category><pubDate>Wed, 24 Jun 2009 06:25:10 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,21932#msg-21932</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,21932#msg-21932</link><description><![CDATA[ @Nicholas_Roge:<br /><br />As jsmaster said, "GX" refers to the graphics library. The functions that start with GX_ control the 3d hardware and let you do things like display polygons. Normally this is what you want to use when you&#039;re making a game because the 3d hardware is specifically designed to do these kind of things, and is very fast.<br /><br />However, that&#039;s not the only way to get things to show up on screen. The way display works on the Wii, you have a block of memory called your "framebuffer" that represents what actually gets displayed. GX works by taking in abstract constructs like polygons, figuring out how to draw them, then drawing the result to the framebuffer. You&#039;re also allowed to write directly to the framebuffer (it&#039;s just ordinary memory after all). This is slower because you don&#039;t get the benefit of hardware acceleration and more complicated because the pixels are stored in a funny format, but for certain types of applications it&#039;s a valid option. Video is one of them, mainly because it doesn&#039;t benefit at all from the 3d hardware but also because you&#039;re already working with the image on a pixel-by-pixel basis so the conversion to the funny format isn&#039;t as big a drawback.<br /><br />If you just want to display a very simple video then the easiest way to show it might be to just store each frame as a texture and quickly cycle through them. It won&#039;t be compressed and you can&#039;t just load an .avi file and expect it to work, but it&#039;s the easiest option using the available tools. You would want to use GX for that.]]></description>
<dc:creator>ulti</dc:creator>
<category>Coding</category><pubDate>Wed, 24 Jun 2009 04:37:41 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,21790#msg-21790</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,21790#msg-21790</link><description><![CDATA[ GX is the "low-level" graphics library for the wii, and is included is libOGC. AFAIK, it is similar to openGL, but I have never used it before, so I am not 100% sure.]]></description>
<dc:creator>jsmaster</dc:creator>
<category>Coding</category><pubDate>Tue, 23 Jun 2009 04:36:42 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,21501#msg-21501</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,21501#msg-21501</link><description><![CDATA[ I don&#039;t know what your rules on bumping are, but I hope three days is enough. I&#039;d really like help on this issue.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Sun, 21 Jun 2009 04:27:46 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,21064#msg-21064</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,21064#msg-21064</link><description><![CDATA[ So, any help on this issue?<br /><br />Edit: And just because I&#039;ve never heard of this GX api doesn&#039;t mean I can&#039;t use it.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Wed, 17 Jun 2009 22:13:35 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20718#msg-20718</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20718#msg-20718</link><description><![CDATA[ If you don&#039;t know what GX is, then you are clearly not the right person to try to not use it.]]></description>
<dc:creator>henke37</dc:creator>
<category>Coding</category><pubDate>Sun, 14 Jun 2009 23:15:38 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20677#msg-20677</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20677#msg-20677</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>alainvey</strong><br />Try adding a check for MP3Player_IsPlaying before stopping playback. This is a guess, of course, but I had a similar problem: I&#039;ve found that if you ask MP3Player to stop when it is not playing, then the program will hang. That, or some other unknown thing fixed my bug.</div></blockquote><br />I added one at the bottom, but the one that tells it to stop when you push A already has a check for that on it. And even when I add that to the bottom, it still freezes.<br /><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>henke37</strong><br />Btw, about video playback, that is one thing that is ok to not use the GX api for, just dump the pixels onto the framebuffer instead.</div></blockquote><br />the GX api? I&#039;m not sure what you mean.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Sun, 14 Jun 2009 17:57:10 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20504#msg-20504</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20504#msg-20504</link><description><![CDATA[ Btw, about video playback, that is one thing that is ok to not use the GX api for, just dump the pixels onto the framebuffer instead.]]></description>
<dc:creator>henke37</dc:creator>
<category>Coding</category><pubDate>Sat, 13 Jun 2009 11:01:12 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20498#msg-20498</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20498#msg-20498</link><description><![CDATA[ Try adding a check for MP3Player_IsPlaying before stopping playback. This is a guess, of course, but I had a similar problem: I&#039;ve found that if you ask MP3Player to stop when it is not playing, then the program will hang. That, or some other unknown thing fixed my bug.]]></description>
<dc:creator>alainvey</dc:creator>
<category>Coding</category><pubDate>Sat, 13 Jun 2009 09:56:48 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20487#msg-20487</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20487#msg-20487</link><description><![CDATA[ Here&#039;s my complete source (It still doesn&#039;t work):<br /><br />main.c<br /><pre class="bbcode">
#include "../../grrlib/GRRLIB/GRRLIB.h"

#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;wiiuse/wpad.h&gt;
#include &lt;dirent.h&gt;
#include &lt;fat.h&gt;

#include "gfx/console.h"
#include "gfx/cursor.h"
#include "colors.h"
#include "properties.h"
#include "additionalFunctions.h"
#include "asndlib.h"
#include "mp3player.h"

//char **artists.name;

Mtx GXmodelView2D;
ir_t ir;

DIR *pdir;
struct dirent *pent;
struct stat statbuf;

int centerTab(tab temp){
	return ((temp.width/2)-((strlen(temp.text)*(8*temp.fontSize))/2));
}
int centerChar(char temp[], int bGObjectWidth, int fontSize){
	return ((bGObjectWidth/2)-(((strlen(temp)*(8*fontSize))/2)));
}
int centerToScreenH(int widthOfObject){
	return (320-(widthOfObject/2));
}
int centerToScreenV(int heightOfObject){
	return (240-(heightOfObject/2));
}


void initializeArtists(){
	int index;
	char dir[40];

	pdir=opendir("SD:/MUSIC");
	
	while (((pent=readdir(pdir))!=NULL)&& artists.output&lt;=(20*artists.page)) {
	    if(artists.output==0){
			strcpy(artists.name[artists.output],"All");
			artists.output++;
		}
		
		if(artists.output==20){
			strcpy(artists.name[artists.output],"&lt;-- - or + --&gt;");
			break;
		}
		
		stat(pent-&gt;d_name,&statbuf);
	    if(strcmp(".", pent-&gt;d_name) == 0 || strcmp("..", pent-&gt;d_name) == 0){
	        continue;
	    }else if(S_ISDIR(statbuf.st_mode)){
			if(strlen(pent-&gt;d_name)&gt;40){
				for(index=0;index&lt;=36;index++){
					dir[index]=pent-&gt;d_name[index];
				}
				for(;index&lt;=39;index++){
					dir[index]=&#039;.&#039;;
				}
			}else{
				strcpy(dir,pent-&gt;d_name);
			}
			strcpy(artists.name[artists.output],dir);
	        artists.output++;
		}else if(!(S_ISDIR(statbuf.st_mode))){
	        continue;
		}
	}
	
	closedir(pdir);
}

void drawArtists(int leftMenuX, GRRLIB_texImg tex_console){
	int artistTitleHeight=150;
	int index;
	
	/*Selection Box*/
	
	for(index=0,artistTitleHeight=150;index&lt;=20;index++,artistTitleHeight+=10){
		if(index==20){
			artistTitleHeight+=10;
		}
		GRRLIB_Printf(40+leftMenuX,artistTitleHeight, tex_console, black, 1, artists.name[index]);
	}
	/*pdir=opendir("SD:/MUSIC");
	while ((pent=readdir(pdir))!=NULL) {
	    stat(pent-&gt;d_name,&statbuf);
		
	    if(strcmp(".", pent-&gt;d_name) == 0 || strcmp("..", pent-&gt;d_name) == 0){
	        continue;
		}else if(S_ISDIR(statbuf.st_mode)){
	        GRRLIB_Printf(40+leftMenuX,artistTitleHeight, tex_console, black, 1, pent-&gt;d_name);//strcpy(artists.name<i>,pent-&gt;d_name);
		}else if(!(S_ISDIR(statbuf.st_mode))){
	        continue;
		}
		
		artistTitleHeight+=10;
	}
	closedir(pdir);*/
}

void menuExit(int exitMenuSelection, GRRLIB_texImg tex_console){

	GRRLIB_Rectangle(centerToScreenH(500),centerToScreenV(340),500, 340, black, 1);
	GRRLIB_Rectangle(centerToScreenH(498),centerToScreenV(338),498, 338, grey, 1);
	
	GRRLIB_Printf(centerChar("Do you really want to Exit?", 640, 2),100,tex_console,black,2,"Do you really want to Exit?");
	
	GRRLIB_Rectangle(centerToScreenH(72), 127+exitMenuSelection, 72, 32, black, 1);
	GRRLIB_Rectangle(centerToScreenH(70), 128+exitMenuSelection, 70, 30, white, 1);
	
	GRRLIB_Printf(centerChar("YES", 640, 2), 140, tex_console, black, 2, "YES");
	GRRLIB_Printf(centerChar("NO", 640, 2), 170, tex_console, black, 2, "NO");	
}	

void mainMenu(){
	int i;
	int leftMenuX=-360;
	int exitMenuSelection=0;
	
	char title[]="Wii Media Player";
	char musicDir[]="SD:/MUSIC/";
	char other[]="Three Days Grace/One X/Never Too Late.mp3";
	char songLocation[1000];
	
	bool leftMenuOpen=false;
	bool exitMenuVisible=false;
	
    u32 buttonDown;
	u32 buttonHeld;
	u32 buttonUp;
	u32 playColor=white;
	
	sprintf(songLocation,"%s%s",musicDir,other);
	
	filepointer=fopen("SD:/MUSIC/Three Days Grace/One X/Never Too Late.mp3","r");
	if(!filepointer){
		exit(0);
	}
		
    // Load the text
    GRRLIB_texImg tex_console = GRRLIB_LoadTexture(console); //Note:  Is an 8x8 font
    GRRLIB_InitTileSet(&tex_console, 8, 8, 0);
	
	//Load Cursor
	GRRLIB_texImg tex_cursor = GRRLIB_LoadTexture(cursor);
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	
	//MP3Player_PlayBuffer (song_mp3, song_mp3_size, NULL);
	MP3Player_Volume(255);
	
	MP3Player_PlayFile(filepointer,reader_callback,0);
	
	ASND_Pause(0);
	
	while(1) {
		WPAD_SetVRes(0, 640, 480);
        WPAD_ScanPads();
        buttonDown = WPAD_ButtonsDown(0);
		buttonHeld = WPAD_ButtonsHeld(0);
		buttonUp = WPAD_ButtonsUp(0);
		WPAD_IR(0, &ir);
		
		/*Catch control events*/
		if(leftMenuOpen && artists.isActive && (buttonDown && WPAD_BUTTON_DOWN)){
			artists.selection+=10;
		}
		if(leftMenuOpen && (buttonDown & WPAD_BUTTON_RIGHT)){
			if(artists.isActive){
				artists.isActive=false;
				albums.isActive=true;
				songs.isActive=false;
			}else if(albums.isActive){
				artists.isActive=false;
				albums.isActive=false;
				songs.isActive=true;
			}
		}
		if(leftMenuOpen && (buttonDown & WPAD_BUTTON_LEFT)){
			if(songs.isActive){
				artists.isActive=false;
				albums.isActive=true;
				songs.isActive=false;
			}else if(albums.isActive){
				artists.isActive=true;
				albums.isActive=false;
				songs.isActive=false;
			}
		}
		if(exitMenuVisible && (buttonDown & WPAD_BUTTON_DOWN)){
			exitMenuSelection=30;
		}
		if(exitMenuVisible && (buttonDown & WPAD_BUTTON_UP)){
			exitMenuSelection=0;
		}
		if(exitMenuVisible && (buttonDown & WPAD_BUTTON_A)){
			if(exitMenuSelection==0){
				break;
			}else if (exitMenuSelection==30){
				exitMenuVisible=false;
			}
		}
		if(!exitMenuVisible && !leftMenuOpen && (buttonHeld & WPAD_BUTTON_A)){
			playColor=mediumDarkGrey;
		}
		if(!exitMenuVisible && !leftMenuOpen && (buttonUp & WPAD_BUTTON_A)){
			playColor=white;
			if(MP3Player_IsPlaying()){
				MP3Player_Stop();
			}else if(!MP3Player_IsPlaying()){
				
			}
		}
		if(leftMenuOpen && (buttonDown & WPAD_BUTTON_PLUS)){
			artists.page++;
		}
		if(leftMenuOpen && artists.page!=0 && (buttonDown & WPAD_BUTTON_MINUS)){
			artists.page++;
		}
		if(buttonDown & WPAD_BUTTON_HOME) {
			exitMenuVisible=true;
        }
		/*--------------------*/
		
        GRRLIB_FillScreen(white);
		
        GRRLIB_Printf(centerChar(title, 640, 3), 60, tex_console, black, 3, title);
		
		/*Draw the frame*/
		GRRLIB_Rectangle(0, 100, 640, 1, black, 0);//Top horizontal bar
		GRRLIB_Rectangle(leftMenuX+380, 101, 1, 379, black, 0);//Left vertical bar
		/*--------------*/
		
		GRRLIB_Rectangle(leftMenuX, 102, 380, 378, grey, 1);//Left menu backgrond
		
		/*Create the play controls*/
		GRRLIB_Rectangle(0, 430, 640, 3, black, 1);//Bottom horizontal bar
		rectangleWithBorder(centerToScreenH(50),395,50,50,black,2,playColor);//Play button
		if(!MP3Player_IsPlaying()){
			for(i=0;i&lt;20;i+=1){
				GRRLIB_Rectangle(310+i,399+i,1,40-(i*2),black, 1);
			}
		}else if(MP3Player_IsPlaying()){
			GRRLIB_Rectangle(305,403,10,35,black,1);
			GRRLIB_Rectangle(324,403,10,35,black,1);
		}
		
		/*Start rollover events*/
		//To open Left Menu
		if(ir.sx&lt;=leftMenuX+380&&ir.sy&gt;=100){
			leftMenuOpen=true;
			if(leftMenuX!=0){
				leftMenuX+=20;
			}
		}else{
			leftMenuOpen=false;
			if(leftMenuX!=-360){
				leftMenuX-=20;
			}
		}
		/*---------------------*/
		
		/*Begin outputting tabs*/
		//Artists tab
		if(artists.isActive){
			artists.fillColor=grey;
		}else{
			artists.fillColor=mediumDarkGrey;
		}
		GRRLIB_Rectangle(leftMenuX+artists.x, artists.y, artists.width, artists.height, artists.borderColor, 0);
		GRRLIB_Rectangle(leftMenuX+artists.x+1, artists.y+1, artists.width-1, artists.height, artists.fillColor, 1);
		if(artists.isActive){
			GRRLIB_Line(leftMenuX+artists.x, artists.y+artists.height, leftMenuX+artists.x+artists.width, artists.y+artists.height, grey);
		}else{
			GRRLIB_Line(leftMenuX+artists.x, artists.y+artists.height, leftMenuX+artists.x+artists.width, artists.y+artists.height, black);
		}
		GRRLIB_Printf(leftMenuX+artists.x+centerTab(artists), artists.y+7, tex_console, black, artists.fontSize, artists.text);
		
		//Albums tab
		if(albums.isActive){
			albums.fillColor=grey;
		}else{
			albums.fillColor=mediumDarkGrey;
		}
		GRRLIB_Rectangle(leftMenuX+albums.x, albums.y, albums.width, albums.height, albums.borderColor, 0);
		GRRLIB_Rectangle(leftMenuX+albums.x+1, albums.y+1, albums.width-1, albums.height, albums.fillColor, 1);
		if(albums.isActive){
			GRRLIB_Line(leftMenuX+albums.x, albums.y+albums.height, leftMenuX+albums.x+albums.width, albums.y+albums.height, grey);
		}else{
			GRRLIB_Line(leftMenuX+albums.x, albums.y+albums.height, leftMenuX+albums.x+albums.width, albums.y+albums.height, black);
		}
		GRRLIB_Printf(leftMenuX+albums.x+centerTab(albums), albums.y+7, tex_console, black, albums.fontSize, albums.text);
		
		//Songs tab
		if(songs.isActive){
			songs.fillColor=grey;
		}else{
			songs.fillColor=mediumDarkGrey;
		}
		GRRLIB_Rectangle(leftMenuX+songs.x, songs.y, songs.width, songs.height, songs.borderColor, 0);
		GRRLIB_Rectangle(leftMenuX+songs.x+1, songs.y+1, songs.width-1, songs.height, songs.fillColor, 1);
		if(songs.isActive){
			GRRLIB_Line(leftMenuX+songs.x, songs.y+songs.height, leftMenuX+songs.x+songs.width, songs.y+songs.height, grey);
		}else{
			GRRLIB_Line(leftMenuX+songs.x, songs.y+songs.height, leftMenuX+songs.x+songs.width, songs.y+songs.height, black);
		}
		GRRLIB_Printf(leftMenuX+songs.x+centerTab(songs), songs.y+7, tex_console, black, songs.fontSize, songs.text);
		/*---------------------*/
		
		/*Begin outputting left menu info*/
		if(artists.isActive){
			drawArtists(leftMenuX, tex_console);
		}/*else if(albums.isActive){
			drawAlbums();
		}else if(songs.isActive){
			drawSongs();
		}*/
		/*---------------------*/
		
		if(exitMenuVisible){
			menuExit(exitMenuSelection, tex_console);
		}
		
		GRRLIB_DrawImg(ir.sx, ir.sy, tex_cursor, 0, 1, 1, 0xFFFFFFFF);
		
        GRRLIB_Render();
    }
	
	// Be a good boy, clear the memory allocated by GRRLIB
    GRRLIB_Exit(); 
    free(tex_console.data);
	free(tex_cursor.data);
	MP3Player_Stop();
	fclose(filepointer);
}

int main() {
    GRRLIB_Init();
    WPAD_Init();
	fatInitDefault();
	ASND_Init();
	MP3Player_Init();
	
	setProperties();
	initializeArtists();
	mainMenu();
	
	exit(0);
	
    return 0;
}

</i></pre><br />Makefile:<br /><pre class="bbcode">
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>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
#---------------------------------------------------------------------------------
GRRLIB        :=    source
TARGET        :=    $(notdir $(CURDIR))
BUILD        :=    build
SOURCES        :=    source source/gfx $(GRRLIB)/GRRLIB $(GRRLIB)/lib/libpng/pngu
DATA        :=    data  
INCLUDES    :=

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS	= -g -O2 -mrvl -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS	=	$(CFLAGS)

LDFLAGS	=	-g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS	:=	-lpng -ljpeg -lz -lwiiuse -lmodplay -lmad -lasnd -lbte -lfat -logc -lm
#---------------------------------------------------------------------------------
# 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), -iquote $(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):
	@echo cleaning...
	@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
	@echo Building...
	@[ -d $@ ] || mkdir -p $@
	@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
	
#---------------------------------------------------------------------------------
clean:
	@echo clean ...
	@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol

#---------------------------------------------------------------------------------
run:
	wiiload $(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
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
# This rule links in binary data with the .mp3 extension
#---------------------------------------------------------------------------------
%.mp3.o :       %.mp3
#---------------------------------------------------------------------------------

	@echo $(notdir $&lt;)
	$(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------</pre><br />Just ask if you need to see any of the custom includes (IE properties.h, colors.h, etc...). Also, if you see anything that can be improved, mention it to me.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Sat, 13 Jun 2009 06:03:33 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20483#msg-20483</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20483#msg-20483</link><description><![CDATA[ Make sure to call ASND_Pause(0); just in case, that turns on ASND]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Sat, 13 Jun 2009 04:32:27 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20454#msg-20454</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20454#msg-20454</link><description><![CDATA[ I am ALMOST there. I&#039;ve just got two more problems. I ran the mp3 in my program, and compiled the source you just posted verbatim (with the exception of changing the file location). The two problems I ran into, with both cases, is that it would act like it&#039;s playing the sound, but you couldn&#039;t hear anything. the second problem I ran into, is that in my program, when I pushed the A button anywhere, it would freeze the system, and the home button in your program did the same thing.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 23:16:39 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20412#msg-20412</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20412#msg-20412</link><description><![CDATA[ Here&#039;s a really simple example of playing an mp3 from a file.<br /><br /><pre class="bbcode">
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <asndlib.h>
#include <mp3player_orig.h>
#include <fat.h>

static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
FILE* the_file = 0;


s32 reader_callback(void *fp,void *dat, s32 size)
{
	return fread(dat,  size, 1, the_file);
}

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

	fatInitDefault();
	
	// Initialise the video system
	VIDEO_Init();
	
	// This function initialises the attached controllers
	WPAD_Init();
	
	// Obtain the preferred video mode from the system
	// This will correspond to the settings in the Wii menu
	rmode = VIDEO_GetPreferredMode(NULL);

	// Allocate memory for the display in the uncached region
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	
	// Initialise the console, required for printf
	console_init(xfb,20,20,rmode-&gt;fbWidth,rmode-&gt;xfbHeight,rmode-&gt;fbWidth*VI_DISPLAY_PIX_SZ);
	
	// Set up the video registers with the chosen mode
	VIDEO_Configure(rmode);
	
	// Tell the video hardware where our display memory is
	VIDEO_SetNextFramebuffer(xfb);
	
	// Make the display visible
	VIDEO_SetBlack(FALSE);

	// Flush the video register changes to the hardware
	VIDEO_Flush();

	// Wait for Video setup to complete
	VIDEO_WaitVSync();
	if(rmode-&gt;viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	
	
    ASND_Init();
    MP3Player_Init();
	MP3Player_Volume(255);
	
	the_file = fopen("sd:/apps/test/1.mp3","r");
	if (!the_file) exit(0);
	
	MP3Player_PlayFile(the_file, reader_callback, 0);

	bool running = true;
	
	while(running) {

		// Call WPAD_ScanPads each loop, this reads the latest controller states
		WPAD_ScanPads();

		// WPAD_ButtonsDown tells us which buttons were pressed in this loop
		// this is a "one shot" state which will not fire again until the button has been released
		u32 pressed = WPAD_ButtonsDown(0);

		// We return to the launcher application via exit
		if ( pressed & WPAD_BUTTON_HOME ) running = false;

		// Wait for the next frame
		VIDEO_WaitVSync();
		
		
	}
	MP3Player_Stop();
	fclose(the_file);
	return 0;
}

</pre>]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 19:31:01 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20409#msg-20409</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20409#msg-20409</link><description><![CDATA[ I was just being overzealous with my includes, perhaps. Whatever had an unknown purpose I left in.<br /><br />Speaking of Tantric, check out his libwiigui library. You can probably just hack a media player together from the template program, but if you&#039;d find that unsatisfying then it still includes some decent media libraries.]]></description>
<dc:creator>alainvey</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 19:06:22 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20400#msg-20400</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20400#msg-20400</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Arikado</strong><br />MP3Player_PlayFile() can play external files.<br /><br />Also, alainvey, AFAIK you dont need to call ASND_Init() or even include the asnd library at all to use mp3player.h.</div></blockquote><br />But you <b>should</b> so that ASND is used :)<br /><br />ASND is DSP accelerated.]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 18:14:49 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20397#msg-20397</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20397#msg-20397</link><description><![CDATA[ MP3Player_PlayFile() can play external files.<br /><br />Also, alainvey, AFAIK you dont need to call ASND_Init() or even include the asnd library at all to use mp3player.h.]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 18:11:55 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20389#msg-20389</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20389#msg-20389</link><description><![CDATA[ I found a post on the matter. But I am running into a problem. It&#039;s compiling with no errors or warnings, but when I go to load it, my television screen becomes a fuzzy green for a split second, and continues to the media player I&#039;m working on. And my play button shows that the song is stopped.<br /><br />Edit: I also seem to be getting consistant memory dumps after exiting.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 17:09:32 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20385#msg-20385</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20385#msg-20385</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>alainvey</strong><br />(this is from buffer only, search this subforum for "sound" to find tips of loading from SD/Fat)</div></blockquote><br />I&#039;m not so sure, but during my searches last week I found several topics related to this. Try searching for "MP3" also. I encountered these posts originally by Googling "play mp3 devkitpro".]]></description>
<dc:creator>alainvey</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 15:57:20 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20371#msg-20371</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20371#msg-20371</link><description><![CDATA[ how can i play files that are not buffers though?]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 15:18:40 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20355#msg-20355</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20355#msg-20355</link><description><![CDATA[ Ok, I recommend reading the asndlib.h and mp3player.h files as scanff suggested, for a more complete listing of the available functions.<br /><br />To get an mp3 working, just do this (this is from buffer only, search this subforum for "sound" to find tips of loading from SD/Fat):<br /><br />Makefile:<br /><br />include libs in the right order - my makefile has this, but you might not need all of these (png and jpeg, for example, though I think -lmad is the mp3 decoder, so keep that):<br /><br /><pre class="bbcode">
-lpng -ljpeg -lz -lwiiuse -lmodplay -lmad -lasnd -lbte -lfat -logc -lm</pre><br /><br />Then, add this to the end of your makefile:<br /><br /><pre class="bbcode">
#---------------------------------------------------------------------------------
# This rule links in binary data with the .mp3 extension
#---------------------------------------------------------------------------------
%.mp3.o :       %.mp3
#---------------------------------------------------------------------------------
       @echo $(notdir $&lt;)
       $(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------</pre><br />That will make your compiler link the necessary files into object files.<br /><br />Now, put the mp3 you wish to play into a "Data" folder in the root of your project (i.e same level as makefile and the folder, "source"). I will call it "song.mp3" for clarity.<br /><br />add to your includes in your main app:<br /><pre class="bbcode">
#include <asndlib.h>
#include <mp3player.h>
#include "song_mp3.h" //yes, the _mp3 is necessary.  This file is generated by the compiler.</pre><br />I recommend just starting with the Hello World template until this works.<br /><br />In your main function, add the following (after video init, if present in main function, and before wpad init - if not present in template, just put it after the Initialise(); call in the main function):<br /><br /><pre class="bbcode">
ASND_Init();
MP3Player_Init();</pre><br />That initialises the sound functionality.<br /><br />To play the file from buffer, then add this:<br /><br /><pre class="bbcode">
MP3Player_PlayBuffer (song_mp3, song_mp3_size, NULL); //just type exactly this.</pre><br />If you used the Hello World template, the main function should now go round and round the while(1) loop until you press Home. The file will play until finished.<br /><br />To stop it, call MP3Player_Stop();<br /><br />Once you&#039;ve got this working, then start playing around to call the function under the conditions you actually want. MP3Player_IsPlaying is a boolean value which you can use to check if an mp3 is playing or not (not a bad idea to do this before you call the PlayBuffer function).<br /><br />If this doesn&#039;t work, let me know.]]></description>
<dc:creator>alainvey</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 10:10:31 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20341#msg-20341</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20341#msg-20341</link><description><![CDATA[ Well... An explanation of the functions, and what to pass to them would be nice, if you wouldn&#039;t mind... An example would be even better though.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 05:41:57 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20298#msg-20298</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20298#msg-20298</link><description><![CDATA[ I recently spent hours trying to get libogc&#039;s mp3 player functions to work. If you have any problems, I&#039;ll check back and post if they&#039;re similar to the ones I had.<br /><br />Seriously, when sounds finally came out, it was like that bit in Die Hard where they get the vault open.]]></description>
<dc:creator>alainvey</dc:creator>
<category>Coding</category><pubDate>Fri, 12 Jun 2009 00:39:40 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20246#msg-20246</guid>
<title>Re: How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20246#msg-20246</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Nicholas_Roge</strong><br />I apologize if this has already been posted and replied to (if it has, I couldn&#039;t find it), but how would one go about playing .mp3&#039;s, .wav&#039;s, .avi&#039;s, .mov, etc... using homebrew? Also, rather than making a new thread, I have another (rather random) question. Is declaring<br /><pre class="bbcode">char characterVariable[20];</pre>
the same thing as calling<br /><pre class="bbcode">char characterVariable;
characterVariable=malloc(20*sizeof(char));</pre>
I&#039;m a complete noob when it comes to pointers and memory management, so this probably isn&#039;t right.</div></blockquote><br /><br /><pre class="bbcode">char characterVariable;
characterVariable=malloc(20*sizeof(char));</pre><br />characterVariable needs to be a pointer and there&#039;s no reason to multiply by size of char as it&#039;s 1. So the allocation needs to be.<br /><br /><pre class="bbcode">char* characterVariable;
characterVariable = (char*)malloc(20);</pre><br />both the char characterVariable[20] and malloc create storage for 20 bytes. the first allocates on the stack the malloc allocates onto the heap.<br /><br /><br />.mp3&#039;s, .wav&#039;s are supported by libogc. (Well PCM sound, which is a wav without the file header). Look at the asndlib.h and mp3player.h header files under the libogc directory.<br /><br />I&#039;m not sure about AVI&#039;s and MOV&#039;s are probably Apple&#039;s IP.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Thu, 11 Jun 2009 18:56:07 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,20240,20240#msg-20240</guid>
<title>How to Play Sound and Video Files</title><link>http://forum.wiibrew.org/read.php?11,20240,20240#msg-20240</link><description><![CDATA[ I apologize if this has already been posted and replied to (if it has, I couldn&#039;t find it), but how would one go about playing .mp3&#039;s, .wav&#039;s, .avi&#039;s, .mov, etc... using homebrew? Also, rather than making a new thread, I have another (rather random) question. Is declaring<br /><pre class="bbcode">char characterVariable[20];</pre>
the same thing as calling<br /><pre class="bbcode">char characterVariable;
characterVariable=malloc(20*sizeof(char));</pre>
I&#039;m a complete noob when it comes to pointers and memory management, so this probably isn&#039;t right.]]></description>
<dc:creator>Nicholas_Roge</dc:creator>
<category>Coding</category><pubDate>Thu, 11 Jun 2009 18:27:33 +0200</pubDate></item>
</channel>
</rss>