// ----------------------------------------------------------------------------------------------------
    #endregion

    #region Audio Playing Methods
    // ----------------------------------------------------------------------------------------------------
    /// <summary>
    /// Plays the associated audio instance.
    /// </summary>
    public void Play()
    {
        if (evt != null)
        {
            Logger.ErrorCheck(evt.Start());
        }
        else
        {
            Logger.Log("Tried to play event without a valid instance: " + path);
            return;
        }
    }
Example #2
0
            // ----------------------------------------------------------------------------------------------------
            #endregion

            #region Loading Methods
            // ----------------------------------------------------------------------------------------------------
            /// <summary>
            /// Forces the load of the Low Level Binary.
            /// </summary>
            /// <returns></returns>
            public static bool ForceLoadLowLevelBinary()
            {
                Logger.Log("Loading Low Level Binary");

                // This is a hack that forces Android to load the .so libraries in the correct order
#if UNITY_ANDROID && !UNITY_EDITOR
                Logger.Log("Loading binaries: " + FMOD.Studio.STUDIO_VERSION.dll + " and " + FMOD.VERSION.dll);
                AndroidJavaClass jSystem = new AndroidJavaClass("java.lang.System");
                jSystem.CallStatic("loadLibrary", FMOD.VERSION.dll);
                jSystem.CallStatic("loadLibrary", FMOD.Studio.STUDIO_VERSION.dll);
#endif

                // Hack: force the low level binary to be loaded before accessing Studio API
#if !UNITY_IPHONE || UNITY_EDITOR
                int temp1, temp2;
                if (!Logger.ErrorCheck(FMOD.Memory.GetStats(out temp1, out temp2)))
                {
                    Logger.LogError("An error occured while loading Low Level Binary!");
                    return(false);
                }
#endif
                Logger.Log("Low Level Binary successfully loaded!");
                return(true);
            }
Example #3
0
    /// <summary>
    /// Gets the streaming asset.
    /// </summary>
    /// <param name="fileName">Name of the file.</param>
    /// <returns></returns>
    private string GetStreamingAsset(string fileName)
    {
        string bankPath = "";

        if (Application.platform == RuntimePlatform.WindowsEditor ||
            Application.platform == RuntimePlatform.OSXEditor ||
            Application.platform == RuntimePlatform.WindowsPlayer ||
            Application.platform == RuntimePlatform.LinuxPlayer
#if PLATFORM_PS4
            || Application.platform == RuntimePlatform.PS4
#endif
#if UNITY_XBOXONE
            || Application.platform == RuntimePlatform.XboxOne
#endif
            )
        {
            bankPath = Application.dataPath + "/StreamingAssets";
        }
        else if (Application.platform == RuntimePlatform.OSXPlayer ||
                 Application.platform == RuntimePlatform.OSXDashboardPlayer)
        {
            bankPath = Application.dataPath + "/Data/StreamingAssets";
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            bankPath = Application.dataPath + "/Raw";
        }
        else if (Application.platform == RuntimePlatform.Android)
        {
            bankPath = "jar:file://" + Application.dataPath + "!/assets";
        }
        else
        {
            Logger.LogError("Unknown platform!");
            return("");
        }

        string assetPath = bankPath + "/" + fileName;

#if UNITY_ANDROID && !UNITY_EDITOR
        // Unpack the compressed JAR file
        string unpackedJarPath = Application.persistentDataPath + "/" + fileName;

        Logger.Log("Unpacking bank from JAR file into:" + unpackedJarPath);

        if (File.Exists(unpackedJarPath))
        {
            Logger.Log("File already unpacked!");
            File.Delete(unpackedJarPath);

            if (File.Exists(unpackedJarPath))
            {
                Logger.Log("Could NOT delete!");
            }
        }

        WWW dataStream = new WWW(assetPath);

        while (!dataStream.isDone)
        {
        }                                    // FIXME: not safe


        if (!String.IsNullOrEmpty(dataStream.error))
        {
            Logger.LogError("WWW Error in Data Stream:" + dataStream.error);
        }

        Logger.Log("Android unpacked jar path: " + unpackedJarPath);

        File.WriteAllBytes(unpackedJarPath, dataStream.bytes);

        //FileInfo fi = new FileInfo(unpackedJarPath);
        //Logger.Log("Unpacked bank size = " + fi.Length);

        assetPath = unpackedJarPath;
#endif

        return(assetPath);
    }