Jump to content


Photo

Full Bg Music Control From Your Controler!


  • Please log in to reply
9 replies to this topic

#1 clif

clif

    X-S Member

  • Members
  • Pip
  • 81 posts

Posted 20 January 2005 - 03:23 AM

Alll the features are:
all functions are to the right thumbstick:
Right: plays if stoped or next track
Left: plays if stoped or previous track
up: plays if stoped or fast forwards if held
Down: stops and returns ambient audio
thumstick down( or click) goes to the next soundtrack, can also have it to dpad left or right so it works globaly threw the dash.

first off find in default/default:
CODE

function MusicPlayerFastForward()
{
var totaltracks = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
if(currentTrack == totaltracks)
{
 currentTrack = 0;
 MusicPlayerPlay();
}
else
{
 currentTrack = currentTrack + 1;
 MusicPlayerPlay();
}
}


and right below it put this in
CODE

function MusicPlayerReWind()
{
var totaltracks = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
if(currentTrack == totaltracks)
{
 currentTrack = 0;
 MusicPlayerPlay();
}
else
{
 currentTrack = currentTrack - 1;
 MusicPlayerPlay();
}
}
function MusicPlayerGo()
{

theMusicPlayer.url = "st:" + theMusicCollection.GetSoundtrackSongID( currentAlbum, currentTrack );
log("Playing " + theMusicPlayer.url);
DisableAmbientAudio();
theMusicPlayer.Play();


}
function MusicPlayerEnd()
{

var totalAlbums = "st:" + theMusicCollection.GetSoundtrackSongID( currentAlbum, currentTrack );
log("Stopping " + theMusicPlayer.url);
EnableAmbientAudio();
theMusicPlayer.Pause();


}


now find:
CODE

//Start and Back buttons are no longer bound to be the same as A and B buttons
//putting these functions here saves alot of pasting to make them all global
function OnBackDown()  { MusicPlayerVolumeUp();   } //back and start buttons
function OnStartDown()  { MusicPlayerVolumeDown(); } //repeat when held down
function OnBlackDown()  { theDiscDrive.OpenTray(); }
function OnWhiteDown()  { theDiscDrive.CloseTray();}

and put this under it:
CODE

function OnRightThumbMoveRight() { MusicPlayerFastForward();}
function OnRightThumbMoveLeft() {MusicPlayerReWind();}
function OnRightThumbMoveUp()   {MusicPlayerGo();}
function OnRightThumbMoveDown()   {MusicPlayerEnd();}

if you wnat to change the soundtrack globaly and not just in the main menu add this under the previous code:
CODE

function OnDPadPressRight() {MusicPlayerRandom();}

now if you want to do it on the thumbstick click or down find:
CODE

control DEF theMainMenuJoy Joystick
{

and put this under it
CODE

function OnRightThumbDown()
{
 MusicPlayerRandom();
}

and thats it, now you have all your functions needed for your bg music, if you need any other ask and i can take a shot at it!

#2 Mad3 Max3

Mad3 Max3

    X-S Enthusiast

  • Members
  • 14 posts
  • Location:Sweden
  • Interests:Bodybuilding,Karate,Aikido,Xbox,Gaming
  • Xbox Version:v1.6

Posted 11 February 2005 - 03:47 AM

One fault in your code! When one the last track it won't reverse. Here's the correction!

this is how the code looks!

CODE

function MusicPlayerReWind()
{
    var totaltracks = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
    if(currentTrack == totaltracks)
    {
         currentTrack = 0;
         MusicPlayerPlay();
    }
    else
    {
         currentTrack = currentTrack - 1;
         MusicPlayerPlay();
    }
}


this is how is should look like!

CODE

function MusicPlayerReWind()
{
    var totaltracks = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
    if(currentTrack == 0)
    {
         currentTrack = totaltracks;  
         MusicPlayerPlay();
    }
    else
    {
         currentTrack = currentTrack - 1;
         MusicPlayerPlay();
    }
}


#3 petermac

petermac

    X-S Senior Member

  • Members
  • PipPip
  • 155 posts
  • Xbox Version:v1.0

Posted 22 March 2005 - 12:17 AM

this is some of the best code for uix... sweet!!!

#4 petermac

petermac

    X-S Senior Member

  • Members
  • PipPip
  • 155 posts
  • Xbox Version:v1.0

Posted 24 March 2005 - 02:12 AM

i need the code for next / previous album, set as if you hold the left trigger, and then press right stick right = next album, right stick left = previous album
thanks

#5 clif

clif

    X-S Member

  • Members
  • Pip
  • 81 posts

Posted 24 March 2005 - 08:23 PM

i havent tested this but this is how it should go;

i cant quite remember how to script to the triggers but serch your defualt/defualt for it and put this code for the triggers and it should work.


CODE

{MusicPlayerRandom();}


if you need more help just ask.

#6 petermac

petermac

    X-S Senior Member

  • Members
  • PipPip
  • 155 posts
  • Xbox Version:v1.0

Posted 25 March 2005 - 01:33 AM

thanks, i have the right stick click coded as {MusicPlayerRandom();}, but is there a way to set them as next album, previous album, cause i have my albums in alphabetical order,- tahanks for help, ohh yeah, sorry about not listing you for credits on my Halo 2 modbox edition skin in the thread Alternate All Code Option Via Uix Skin,
thx

#7 clif

clif

    X-S Member

  • Members
  • Pip
  • 81 posts

Posted 25 March 2005 - 05:35 AM

if you mad a new code (if thers not one already) call it musicplayerprev and musicplayernext

to code it find the original function for musicplayerrandom witch looks like this:
CODE

function MusicPlayerRandom()
{
theMusicPlayer.playbackMode = 2;
var totalAlbums = theMusicCollection.GetSoundtrackCount() - 1;
var a = Math.random() * totalAlbums;
currentAlbum = Math.round(a);
var totalTracks = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
var b = Math.random() * totalTracks;
currentTrack = Math.round(b);
MusicPlayerPlay();
}

now make a new one like this:
CODE

function MusicPlayerNext()
{
        var totalalbums = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
if(currentAlbum == totalalbums)
{
 currentAlbum = 0;
 MusicPlayerPlay();
}
else
{
 currentAlbum = currentAlbum + 1;
 MusicPlayerPlay();
}
MusicPlayerPlay();
}
     


try this code to see if it works to test it you can just rename the cose to MusicPlayerRandom() but if you do that put the other one to MusicPlayerRandomBackup() then go into uix and test to see if it works. if so let me know. i would have tried this but my xbox shuts off every 5 seconds beacuse of the soldering on the PSU, so i will try it later beacuse i do not have the time right now to take my box apart. i will check back later.

#8 petermac

petermac

    X-S Senior Member

  • Members
  • PipPip
  • 155 posts
  • Xbox Version:v1.0

Posted 25 March 2005 - 08:21 AM

This is the code i used, yours worked, thanks, it had a few bugs, but i fixed half of them
I coded them as

function OnBlackDown() { MusicPlayerNext();}
function OnWhiteDown() { MusicPlayerPrevious();}

The only bug that this still has is that when you hit white or black, if you are on track 6, (or any #) you will be on that number in the next album
strangely, i could not find the code to set the track back to 1 or first track in the album,
any way, heres the code, like clif said find function MusicPlayerRandom(), and under that function add this
CODE

function MusicPlayerNext()
{
var totalalbums = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
if(currentAlbum == totalalbums)
{
currentAlbum = 0;
MusicPlayerPlay();
}
else
{
currentAlbum = currentAlbum + 1;
MusicPlayerPlay();
}
}

function MusicPlayerPrevious()
{
var totalalbums = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
if(currentAlbum == totalalbums)
{
currentAlbum = 0;
MusicPlayerPlay();
}
else
{
currentAlbum = currentAlbum - 1;
MusicPlayerPlay();
}
}

do you think you could fix that code error? where the track stays that number on next album?

Edited by petermac, 25 March 2005 - 08:23 AM.


#9 clif

clif

    X-S Member

  • Members
  • Pip
  • 81 posts

Posted 26 March 2005 - 06:21 AM

um could try some code to reset it to the first track, i can look into it later, but im glad to here that my code worked beacuse that was the first code i made in like a month and i dint even test it, and it worked. so yea i can look into it a bit.

#10 petermac

petermac

    X-S Senior Member

  • Members
  • PipPip
  • 155 posts
  • Xbox Version:v1.0

Posted 26 March 2005 - 07:28 AM

got it, had to add a few lines, now my next code proct is to show the album info, and maybe even the track time, any help?
thanks

heres working code coded as
CODE
function OnBlackDown() { MusicPlayerNext();}
function OnWhiteDown() { MusicPlayerPrevious();}



CODE

function MusicPlayerNext()
{
var totalalbums = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
var totalTracks = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
if(currentAlbum == totalalbums)
{
currentAlbum = 0;
MusicPlayerPlay();
}
else
{
currentAlbum = currentAlbum + 1;
currentTrack = 0;
MusicPlayerPlay();
}
}

function MusicPlayerPrevious()
{
var totalalbums = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
var totalTracks = theMusicCollection.GetSoundtrackSongCount(currentAlbum) - 1;
if(currentAlbum == totalalbums)
{
currentAlbum = 0;
MusicPlayerPlay();
}
else
{
currentAlbum = currentAlbum - 1;
currentTrack = 0;
MusicPlayerPlay();
}
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users