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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileAudioStream(File file) FileAudioStream(File file, AudioFormat format) FileAudioStream(File file, AudioFormat format, boolean isTemporaryFile) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voiddispose()Returns a new, fully independent stream instance, which can be read and closed without impacting the original instance.Gets the supported audio formatlonglength()Provides the length of the stream in bytes.voidmark(int readlimit) booleanintread()voidreset()Methods inherited from class org.openhab.core.audio.AudioStream
getIdMethods 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:AudioStreamGets the supported audio format- Specified by:
getFormatin classAudioStream- Returns:
- The supported audio format
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
length
public long length()Description copied from interface:SizeableAudioStreamProvides the length of the stream in bytes.- Specified by:
lengthin interfaceSizeableAudioStream- Returns:
- absolute length in bytes
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
getClonedStream
Description copied from interface:ClonableAudioStreamReturns a new, fully independent stream instance, which can be read and closed without impacting the original instance.- Specified by:
getClonedStreamin interfaceClonableAudioStream- Returns:
- a new input stream that can be consumed by the caller
- Throws:
AudioException- if stream cannot be created
-
dispose
- Specified by:
disposein interfaceDisposable- Throws:
IOException
-