Jump to content

Streaming of audio files.


Fella

Recommended Posts

Hello, I'm owner of a race server and recently when i was uploading new maps on my server, i noticed that one of the maps was different from the others. The main difference was this script that this map had. Here it is:

function startMusic() 
    setRadioChannel(0) 
    song = playSound("http://vita.gamers-board.com/serverfiles/race/[DM]D4r133l_-v3-_InvaderS_II.mp3",true) 
    outputChatBox("") 
end 
  
function makeRadioStayOff() 
    setRadioChannel(0) 
    cancelEvent() 
end 
  
function toggleSong() 
    if not songOff then 
        setSoundVolume(song,0) 
        songOff = true 
        removeEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) 
    else 
        setSoundVolume(song,1) 
        songOff = false 
        setRadioChannel(0) 
        addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) 
    end 
end 
  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic) 
addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) 
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff) 
addCommandHandler("musicmusic",toggleSong) 
bindKey("m","down","musicmusic") 
addEventHandler("onClientResourceStop",getResourceRootElement(getThisResource()),startMusic) 
  

I'm pretty sure that many of you understood already what it does, but still, I'll explain it the way i see it.

Basically, instead of making players download the song that this map had, it made them connect to some external server (in this case http://vita.gamers-board.com) and stream it.

This really amazed me, so the next thing i did, i took some random map, cut the music of it and uploaded it to the dropbox (i know it might not be best option ever, but I'm aware that with help of dropbox you can create kinda your own radio stations and stream the music that you've uploaded), I mean if with dropbox you can stream music to iphones, pcs and so on, why can't you do the same thing in mta, i mean what's the difference, right? But unfortunately, there was some difference, since even though i'd edited the meta and changed the path to the music i still wasn't able to get it to work, basically i just got some odd error message like "could reach the file" or something like that.

So, as you can see, even though my first attempt at streaming music wasn't as successful and glorious as i hoped it would be, I'm still eager to know how to make it right. Do i need to buy some very own external server just to be able to stream music or there's already a free dicision like dropbox or opentape for audio streaming in mta or, if i have a vps, i can stream music directly from the resource-cache folder with help of Apache? In other words, what are the requirements for streaming audio files instead of downloading them?

Well, i think that's it and thanks in advance for your help. :)

Link to comment
Just pass the link of the sound file to playSound, it can be wherever you want.
playSound( "http://www.your-website.com/Your_music.mp3", false ); 

i took some random map, cut the music of it and uploaded it to the dropbox, I mean if with dropbox you can stream music to iphones, pcs and so on, why can't you do the same thing in mta, i mean what's the difference, right? But unfortunately, there was some difference, since even though i'd edited the meta and changed the path to the music i still wasn't able to get it to work, basically i just got some odd error message like "could reach the file" or something like that.
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...