Package org.openhab.core.audio
Class FileAudioStream
java.lang.Object
java.io.InputStream
org.openhab.core.audio.AudioStream
org.openhab.core.audio.FixedLengthAudioStream
org.openhab.core.audio.FileAudioStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClonableAudioStream
,SizeableAudioStream
,Disposable
This is an AudioStream from an audio file
- Author:
- Karel Goderis - Initial contribution, Kai Kreuzer - Refactored to take a file as input, Christoph Weitkamp - Refactored use of filename extension
-
Field Summary
-
Constructor Summary
ConstructorDescriptionFileAudioStream
(File file) FileAudioStream
(File file, AudioFormat format) FileAudioStream
(File file, AudioFormat format, boolean isTemporaryFile) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
dispose()
Returns a new, fully independent stream instance, which can be read and closed without impacting the original instance.Gets the supported audio formatlong
length()
Provides the length of the stream in bytes.void
mark
(int readlimit) boolean
int
read()
void
reset()
Methods inherited from class org.openhab.core.audio.AudioStream
getId
Methods inherited from class java.io.InputStream
available, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferTo
-
Field Details
-
WAV_EXTENSION
- See Also:
-
MP3_EXTENSION
- See Also:
-
OGG_EXTENSION
- See Also:
-
AAC_EXTENSION
- See Also:
-
-
Constructor Details
-
FileAudioStream
- Throws:
AudioException
-
FileAudioStream
- Throws:
AudioException
-
FileAudioStream
public FileAudioStream(File file, AudioFormat format, boolean isTemporaryFile) throws AudioException - Throws:
AudioException
-
-
Method Details
-
getFormat
Description copied from class:AudioStream
Gets the supported audio format- Specified by:
getFormat
in classAudioStream
- Returns:
- The supported audio format
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
length
public long length()Description copied from interface:SizeableAudioStream
Provides the length of the stream in bytes.- Specified by:
length
in interfaceSizeableAudioStream
- Returns:
- absolute length in bytes
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
getClonedStream
Description copied from interface:ClonableAudioStream
Returns a new, fully independent stream instance, which can be read and closed without impacting the original instance.- Specified by:
getClonedStream
in interfaceClonableAudioStream
- Returns:
- a new input stream that can be consumed by the caller
- Throws:
AudioException
- if stream cannot be created
-
dispose
- Specified by:
dispose
in interfaceDisposable
- Throws:
IOException
-