arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AudioSourceSMB Class Reference

An AudioSource that uses the SMBClient of the https://github.com/pschatzmann/TinySMB library to retrieve the files from a Windows, macOS, Samba or NAS share. You need to provide an SMBClient object to the constructor and make sure that you call begin() on it before you access the files. More...

#include <AudioSourceSMB.h>

Inheritance diagram for AudioSourceSMB:
AudioSource

Public Member Functions

 AudioSourceSMB (smb::SMBClient &client, const char *path="/", const char *ext=nullptr, int files=0)
 
bool begin () override
 Counts the audio files in the start directory.
 
void end ()
 Closes the actual file.
 
int index () override
 Returns the actual index of the stream.
 
virtual bool isAutoNext ()
 Returns default setting go to the next.
 
Stream * nextStream (int offset) override
 Returns next audio stream.
 
Stream * operator[] (int idx)
 access with array syntax
 
Stream * previousStream (int offset) override
 Returns previous audio stream.
 
Stream * selectStream (const char *path) override
 
Stream * selectStream (int index) override
 
virtual void setAutoNext (bool flag)
 
void setBufferSize (size_t size)
 Defines the read buffer size of the opened files (default 4096)
 
void setDirectory (const char *path)
 Defines the start directory: call begin() afterwards.
 
void setFileExtension (const char *ext)
 Defines the file extension filter (e.g. "mp3"): nullptr for all files.
 
virtual Stream * setIndex (int index)
 same as selectStream - I just prefer this name
 
void setMaxFiles (int maxCount)
 Defines the max number of files (if value is >0)
 
virtual bool setMetadataCallback (void(*fn)(MetaDataType info, const char *str, int len), ID3TypeSelection sel=SELECT_ICY)
 
virtual void setTimeout (int millisec)
 Sets the timeout of Stream in milliseconds.
 
virtual void setTimeoutAutoNext (int millisec)
 
size_t size ()
 Returns the number of files that were found by begin()
 
virtual int timeoutAutoNext ()
 Provides the timeout which is triggering to move to the next stream.
 
const char * toStr () override
 provides the actual file name with path
 

Protected Member Functions

bool endsWith (const char *file, const char *ext)
 
bool isMaxReached (int n)
 
bool isValidIdx (int index)
 
Stream * openFile (const char *path)
 
bool walk (Str &dir, int target, int &n, Str *result)
 

Protected Attributes

size_t buffer_size = 0
 
Str directory
 
smb::SMBFile file
 
int file_count = -1
 
int idx = 0
 
bool is_auto_next = true
 
size_t max_files = 0
 
smb::SMBClient * p_client = nullptr
 
const char * p_ext = nullptr
 
int timeout_auto_next_value = 500
 

Detailed Description

An AudioSource that uses the SMBClient of the https://github.com/pschatzmann/TinySMB library to retrieve the files from a Windows, macOS, Samba or NAS share. You need to provide an SMBClient object to the constructor and make sure that you call begin() on it before you access the files.

The directory is scanned recursively and the files that match the extension are played in the order in which the server lists them. The file names are not stored: the share is listed each time a new file is selected, so only the name of the actual file is kept in memory.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioSourceSMB()

AudioSourceSMB ( smb::SMBClient &  client,
const char *  path = "/",
const char *  ext = nullptr,
int  files = 0 
)
inline

Default constructor: provide the (opened) SMBClient, the start directory relative to the share, the file extension and optionally the max number of files (0 = unlimited)

Member Function Documentation

◆ begin()

bool begin ( )
inlineoverridevirtual

Counts the audio files in the start directory.

Implements AudioSource.

◆ end()

void end ( )
inline

Closes the actual file.

◆ endsWith()

bool endsWith ( const char *  file,
const char *  ext 
)
inlineprotected

◆ index()

int index ( )
inlineoverridevirtual

Returns the actual index of the stream.

Reimplemented from AudioSource.

◆ isAutoNext()

virtual bool isAutoNext ( )
inlinevirtualinherited

◆ isMaxReached()

bool isMaxReached ( int  n)
inlineprotected

◆ isValidIdx()

bool isValidIdx ( int  index)
inlineprotected

◆ nextStream()

Stream * nextStream ( int  offset)
inlineoverridevirtual

Returns next audio stream.

Implements AudioSource.

◆ openFile()

Stream * openFile ( const char *  path)
inlineprotected

◆ operator[]()

Stream * operator[] ( int  idx)
inlineinherited

access with array syntax

◆ previousStream()

Stream * previousStream ( int  offset)
inlineoverridevirtual

Returns previous audio stream.

Reimplemented from AudioSource.

◆ selectStream() [1/2]

Stream * selectStream ( const char *  path)
inlineoverridevirtual

Opens the indicated file. If the path is a directory, it becomes the new start directory and the first file is opened.

Implements AudioSource.

◆ selectStream() [2/2]

Stream * selectStream ( int  index)
inlineoverridevirtual

Returns audio stream at the indicated index (the index is zero based, so the first value is 0!)

Reimplemented from AudioSource.

◆ setAutoNext()

virtual void setAutoNext ( bool  flag)
inlinevirtualinherited

Reimplemented in AudioSourceCallback.

◆ setBufferSize()

void setBufferSize ( size_t  size)
inline

Defines the read buffer size of the opened files (default 4096)

◆ setDirectory()

void setDirectory ( const char *  path)
inline

Defines the start directory: call begin() afterwards.

◆ setFileExtension()

void setFileExtension ( const char *  ext)
inline

Defines the file extension filter (e.g. "mp3"): nullptr for all files.

◆ setIndex()

virtual Stream * setIndex ( int  index)
inlinevirtualinherited

same as selectStream - I just prefer this name

◆ setMaxFiles()

void setMaxFiles ( int  maxCount)
inline

Defines the max number of files (if value is >0)

◆ setMetadataCallback()

virtual bool setMetadataCallback ( void(*)(MetaDataType info, const char *str, int len)  fn,
ID3TypeSelection  sel = SELECT_ICY 
)
inlinevirtualinherited

Reimplemented in AudioSourceURL.

◆ setTimeout()

virtual void setTimeout ( int  millisec)
inlinevirtualinherited

Sets the timeout of Stream in milliseconds.

Reimplemented in AudioSourceURL.

◆ setTimeoutAutoNext()

virtual void setTimeoutAutoNext ( int  millisec)
inlinevirtualinherited

Sets the timeout which is triggering to move to the next stream. - the default value is 500 ms

◆ size()

size_t size ( )
inline

Returns the number of files that were found by begin()

◆ timeoutAutoNext()

virtual int timeoutAutoNext ( )
inlinevirtualinherited

Provides the timeout which is triggering to move to the next stream.

◆ toStr()

const char * toStr ( )
inlineoverridevirtual

provides the actual file name with path

Reimplemented from AudioSource.

◆ walk()

bool walk ( Str &  dir,
int  target,
int &  n,
Str *  result 
)
inlineprotected

Lists the directory recursively and counts the matching files in n. If target >= 0 we stop at the file with this index and provide its path in result. Returns false if the directory could not be listed.

Member Data Documentation

◆ buffer_size

size_t buffer_size = 0
protected

◆ directory

Str directory
protected

◆ file

smb::SMBFile file
protected

◆ file_count

int file_count = -1
protected

◆ idx

int idx = 0
protected

◆ is_auto_next

bool is_auto_next = true
protectedinherited

◆ max_files

size_t max_files = 0
protected

◆ p_client

smb::SMBClient* p_client = nullptr
protected

◆ p_ext

const char* p_ext = nullptr
protected

◆ timeout_auto_next_value

int timeout_auto_next_value = 500
protectedinherited

The documentation for this class was generated from the following file: