/// <summary> /// Initializes a new instance of the <see cref="FMODTrack" /> class. /// </summary> /// <param name="fmodSound">The fmod sound.</param> /// <param name="system">The system.</param> /// <param name="file">The file.</param> public FMODTrack(Sound fmodSound, global::FMOD.System system, string file) { fmodSound.Guard("fmodSound"); system.Guard("system"); this.fmodSound = fmodSound; this.file = file; Length = TimeSpan.FromMilliseconds(GetLengthMs(fmodSound)); fmodChannel = CreateChannel(system, fmodSound); Init(); }
/// <summary> /// Creates the channel. /// </summary> /// <param name="system">The system.</param> /// <param name="sound">The sound.</param> /// <returns></returns> private static Channel CreateChannel(global::FMOD.System system, Sound sound) { Channel channel = null; var result = system.playSound(CHANNELINDEX.FREE, sound, true, ref channel); if (result != RESULT.OK) { throw FMODPlayer.GetException("Unable to play sound", result); } return(channel); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { disposed = true; if (fmodSystem == null) { return; } var result = fmodSystem.close(); if (result != RESULT.OK) { throw GetException("Unable to close FMOD System", result); } fmodSystem = null; }
/// <summary> /// Initializes a new instance of the <see cref="FMODPlayer" /> class. /// </summary> /// <param name="configurationManager">The configuration manager.</param> public FMODPlayer(IConfigurationManager configurationManager) { configurationManager.Guard("configurationManager"); this.configurationManager = configurationManager; fmodSystem = new global::FMOD.System(); var result = Factory.System_Create(ref fmodSystem); if (result != RESULT.OK) { throw GetException("Unable to create FMOD System", result); } result = fmodSystem.init(10, INITFLAGS.NORMAL, IntPtr.Zero); if (result != RESULT.OK) { throw GetException("Unable to Initialize FMOD System", result); } GetPlugins(); }