Exemplo n.º 1
0
        public bool Play(string filename, bool loop)
        {
            Stop();

            // FIXME: How about using AudioStream::openStreamFile instead of the code below?
            // I.e.:
            //_audioSource = Audio::AudioStream::openStreamFile(fileBase, 0, 0, loop ? 0 : 1);

            if (ServiceLocator.AudioManager == null)
            {
                return(false);
            }

            IRewindableAudioStream stream = ServiceLocator.AudioManager.MakeStream(filename);

            if (stream == null)
            {
                return(false);
            }

            _audioSource = new LoopingAudioStream(stream, loop ? 0 : 1);

            FadeUp();
            return(true);
        }
Exemplo n.º 2
0
        public LoopingAudioStream(IRewindableAudioStream stream, int loops, bool disposeAfterUse = true)
        {
            _parent          = stream;
            _loops           = loops;
            _disposeAfterUse = disposeAfterUse;

            if (!stream.Rewind())
            {
                // TODO: Properly indicate error
                _loops = _completeIterations = 1;
            }
            if (stream.IsEndOfStream)
            {
                // Apparently this is an empty stream
                _loops = _completeIterations = 1;
            }
        }
Exemplo n.º 3
0
        public IRewindableAudioStream MakeStream(string filename)
        {
            IRewindableAudioStream stream = null;

            var path = LocatePath(filename + ".*");

            if (path == null)
            {
                return(null);
            }

            if (string.Equals(Path.GetExtension(path), ".flac", StringComparison.OrdinalIgnoreCase) || string.Equals(Path.GetExtension(path), ".fla", StringComparison.OrdinalIgnoreCase))
            {
                stream = (IRewindableAudioStream)MakeFlacStream(File.OpenRead(path));
            }
            return(stream);
        }