private static extern RESULT FMOD_Sound_GetOpenState(IntPtr sound, ref OPENSTATE openstate, ref uint percentbuffered, ref int starving);
private static extern RESULT FMOD_Sound_GetOpenState (IntPtr sound, out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy);
public RESULT getOpenState(ref OPENSTATE openstate, ref uint percentbuffered, ref bool starving) { RESULT result; int s = 0; result = FMOD_Sound_GetOpenState(soundraw, ref openstate, ref percentbuffered, ref s); starving = (s != 0); return result; }
public RESULT getOpenState(ref OPENSTATE openstate, ref uint percentbuffered, ref bool starving) { return FMOD_Sound_GetOpenState(soundraw, ref openstate, ref percentbuffered, ref starving); }
public RESULT getOpenState (out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy) { return FMOD_Sound_GetOpenState(rawPtr, out openstate, out percentbuffered, out starving, out diskbusy); }
/// <summary> /// Takes a url and plays the audio found there /// </summary> /// <returns>The stream from internet.</returns> /// <param name="url">URL.</param> /// <param name="soundReturn">Sound return.</param> public static void PlaySoundFromNet(string url, out Sound _sound, out Channel _channel, out InternetStreamData _streamData) { // Low level FMOD.System system; ChannelGroup channelGroup; Sound sound; Channel channel; // Result and network enum RESULT result = RESULT.OK; OPENSTATE openState = OPENSTATE.READY; // Declare system = RuntimeManager.LowlevelSystem; system.getMasterChannelGroup(out channelGroup); // Sound will be put on master channel group // Increase stream buffer size to account for internet lag // FMOD's example uses TIMEUNIT.RAWBYTES (8 bytes) but this caused the buffer to fill and the file to stop playing // TIMUNIT.PCMFRACTION is 16 bytes and has meant the file keeps playing result = system.setStreamBufferSize(64 * 1024, TIMEUNIT.PCMFRACTION); // Allocate memory for new sound object CREATESOUNDEXINFO exInfo = new CREATESOUNDEXINFO(); exInfo.cbsize = Marshal.SizeOf(typeof(CREATESOUNDEXINFO)); exInfo.filebuffersize = 1024 * 16; // Increase the default chunk size to hanlde seeking inside large playlist files that me be over 2kb // Create sound and return the sound object. Non blocking meaning it is opened / prepared in the background. sound.getOpenState gets the info about its loading result = system.createSound(url, MODE.CREATESTREAM | MODE.NONBLOCKING, ref exInfo, out sound); // Return if creating sound failed if (result != RESULT.OK) { UnityEngine.Debug.LogError("FMOD Extensions: Failed to create sound from net. " + result); _sound = new Sound(); _channel = new Channel(); _streamData = new InternetStreamData(); return; } _sound = sound; // Info data returning from the sound object InternetStreamData streamData = new InternetStreamData(0, 0, false, false, false, false, "Stopped"); // Main function for getting the information from the sound object result = sound.getOpenState(out openState, out streamData.percent, out streamData.isStarving, out streamData.isDiskBusy); // Return error message if we can't get the state of the sound if (result != RESULT.OK) { UnityEngine.Debug.LogError("FMOD Extensions: Could not get open state of file. " + result); _sound = new Sound(); _channel = new Channel(); _streamData = new InternetStreamData(); return; } // Wait for file to become ready / for it to play while (openState != OPENSTATE.READY) { result = sound.getOpenState(out openState, out streamData.percent, out streamData.isStarving, out streamData.isDiskBusy); } result = system.playSound(sound, channelGroup, false, out channel); _channel = channel; if (!channel.hasHandle()) { result = sound.getOpenState(out openState, out streamData.percent, out streamData.isStarving, out streamData.isDiskBusy); channel.getPaused(out streamData.isPaused); channel.isPlaying(out streamData.isPlaying); channel.getPosition(out streamData.pos, TIMEUNIT.MS); channel.setVolume(1f); UnityEngine.Debug.LogFormat("{0} {1} {2}", streamData.isPaused, streamData.isPlaying, streamData.pos); } channel.getPaused(out streamData.isPaused); channel.isPlaying(out streamData.isPlaying); channel.getPosition(out streamData.pos, TIMEUNIT.MS); if (openState == OPENSTATE.BUFFERING) { streamData.state = "Buffering"; } else if (openState == OPENSTATE.CONNECTING) { streamData.state = "Connecting..."; } else if (streamData.isPaused) { streamData.state = "Paused"; } else if (streamData.isPlaying) { streamData.state = "Playing"; } _streamData = streamData; UnityEngine.Debug.Log("FMOD Extensions: Successfully created stream from net"); }
private static extern RESULT FMOD5_Sound_GetOpenState(IntPtr sound, out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy);
public RESULT getOpenState(out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy) { return(FMOD5_Sound_GetOpenState(handle, out openstate, out percentbuffered, out starving, out diskbusy)); }
private static extern RESULT FMOD_Sound_GetOpenState(IntPtr sound, ref OPENSTATE openstate, ref uint percentbuffered, ref bool starving);
public RESULT getOpenState(ref OPENSTATE openstate, ref uint percentbuffered, ref bool starving) { return(Sound.FMOD_Sound_GetOpenState(soundraw, ref openstate, ref percentbuffered, ref starving)); }