상속: Disposable, AudioI
예제 #1
0
        public SoundWAV(DisposableI parent, string fileName, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback)
            : base(parent)
        {
            try
            {
                audio = parent.FindParentOrSelfWithException<Audio>();
                audio.UpdateCallback += Update;

                loadedFromContent = true;
                sound = parent.FindParentOrSelfWithException<RootDisposable>().Content.Load<SoundEffect>(Streams.StripFileExt(fileName));

                for (int i = 0; i != instanceCount; ++i)
                {
                    inactiveInstances.AddLast(new SoundWAVInstance(this, looped));
                }
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null) loadedCallback(this, false);
                return;
            }

            Loaded = true;
            if (loadedCallback != null) loadedCallback(this, true);
        }
예제 #2
0
        public Music(DisposableI parent, string fileName)
            : base(parent)
        {
            audio = parent.FindParentOrSelfWithException<Audio>();
            audio.UpdateCallback += Update;

            song = parent.FindParentOrSelfWithException<RootDisposable>().Content.Load<Song>(Streams.StripFileExt(fileName));
            MediaPlayer.IsRepeating = true;
        }