Example #1
0
        /// <summary>
        /// Creates an audio player channel.
        /// </summary>
        /// <returns></returns>
        public IAudioPlayerChannel CreateAudioPlayerChannel()
        {
            IAudioPlayerChannel channel = null;

#if IOS_NATIVE
            if (Application.isMobilePlatform && EnableBackgroundAudio)
            {
                // TODO: the native channels need to be able to support streaming
                // loading, otherwise they block for too long.
                channel = new IOSAudioPlayerChannel();
            }
#endif
#if ANDROID_NATIVE
            if (Application.isMobilePlatform && EnableBackgroundAudio)
            {
                channel = new OpenSLAudioPlayerChannel();
            }
#endif

            if (channel == null)
            {
                channel = gameObject.AddComponent <UnityAudioPlayerChannel>();
            }

            return(channel);
        }
Example #2
0
        /// <summary>
        /// Creates a spatial audio player channel for positional sound.
        /// </summary>
        /// <returns></returns>
        public ISpatialAudioPlayerChannel CreateSpatialAudioPlayerChannel()
        {
            ISpatialAudioPlayerChannel channel = null;

#if IOS_NATIVE_NOT_SUPPORTED
            if (Application.isMobilePlatform && EnableBackgroundAudio)
            {
                channel = new IOSAudioPlayerChannel();
            }
#endif

            if (channel == null)
            {
                channel = gameObject.AddComponent <UnitySpatialAudioPlayerChannel>();
            }

            return(channel);
        }