arduino-audio-tools
Loading...
Searching...
No Matches
AudioSourceFTP< ClientType > Class Template Reference

An AudioSource that uses the https://github.com/pschatzmann/TinyFTPClient library to retrieve files from a FTP Server. You need to provide an FTPClient object to the constructor and make sure that you open it before you access the files. More...

#include <AudioSourceFTP.h>

Inheritance diagram for AudioSourceFTP< ClientType >:
AudioSource

Public Member Functions

 AudioSourceFTP (FTPClient< ClientType > &client, const char *path, const char *ext, int files=0)
bool begin () override
 Checks that the directory contains some files.
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 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

Protected Member Functions

int count ()
 Lists the directory and counts the matching files.
bool endsWith (const char *file, const char *ext)
bool findFile (int index, Str &path)
 Lists the directory and provides the path of the n-th matching file.
bool isValidIdx (int index)
Stream * openFile (const char *path)
void toPath (const char *name, Str &result)
 Some servers list the names with the directory, others without it.

Protected Attributes

Str directory
FTPFile file
int file_count = -1
int idx = 0
bool is_auto_next = true
size_t max_files = 0
FTPClient< ClientType > * p_client = nullptr
const char * p_ext = nullptr
int timeout_auto_next_value = 500

Detailed Description

template<class ClientType>
class audio_tools::AudioSourceFTP< ClientType >

An AudioSource that uses the https://github.com/pschatzmann/TinyFTPClient library to retrieve files from a FTP Server. You need to provide an FTPClient object to the constructor and make sure that you open it before you access the files.

The file names are not stored: the directory is listed on the server each time a new file is selected and the n-th matching file is opened. So only the name of the actual file is kept in memory.

Note
supported only by Arduino platforms!
Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioSourceFTP()

template<class ClientType>
AudioSourceFTP ( FTPClient< ClientType > & client,
const char * path,
const char * ext,
int files = 0 )
inline

Default constructor: Provide the client class as template argument e.g. AudioSourceFTP<WiFiClient> source(client, path, ext);.

Member Function Documentation

◆ begin()

template<class ClientType>
bool begin ( )
inlineoverridevirtual

Checks that the directory contains some files.

Implements AudioSource.

◆ count()

template<class ClientType>
int count ( )
inlineprotected

Lists the directory and counts the matching files.

◆ end()

template<class ClientType>
void end ( )
inline

Closes the actual file.

◆ endsWith()

template<class ClientType>
bool endsWith ( const char * file,
const char * ext )
inlineprotected

◆ findFile()

template<class ClientType>
bool findFile ( int index,
Str & path )
inlineprotected

Lists the directory and provides the path of the n-th matching file.

◆ index()

template<class ClientType>
int index ( )
inlineoverridevirtual

Returns the actual index of the stream.

Reimplemented from AudioSource.

◆ isAutoNext()

◆ isValidIdx()

template<class ClientType>
bool isValidIdx ( int index)
inlineprotected

◆ nextStream()

template<class ClientType>
Stream * nextStream ( int offset)
inlineoverridevirtual

Returns next audio stream.

Implements AudioSource.

◆ openFile()

template<class ClientType>
Stream * openFile ( const char * path)
inlineprotected

◆ operator[]()

Stream * operator[] ( int idx)
inlineinherited

access with array syntax

◆ previousStream()

template<class ClientType>
Stream * previousStream ( int offset)
inlineoverridevirtual

Returns previous audio stream.

Reimplemented from AudioSource.

◆ selectStream() [1/2]

template<class ClientType>
Stream * selectStream ( const char * path)
inlineoverridevirtual

Opens the indicated file: if the path does not match the file extension it is considered to be a directory and the first file is opened.

Implements AudioSource.

◆ selectStream() [2/2]

template<class ClientType>
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.

◆ setFileExtension()

template<class ClientType>
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()

template<class ClientType>
void setMaxFiles ( int maxCount)
inline

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

◆ setMetadataCallback()

virtual bool setMetadataCallback ( void(* fn )(MetaDataType info, const char *str, int len),
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()

template<class ClientType>
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.

◆ toPath()

template<class ClientType>
void toPath ( const char * name,
Str & result )
inlineprotected

Some servers list the names with the directory, others without it.

◆ toStr()

template<class ClientType>
const char * toStr ( )
inlineoverridevirtual

provides the actual file name

Reimplemented from AudioSource.

Member Data Documentation

◆ directory

template<class ClientType>
Str directory
protected

◆ file

template<class ClientType>
FTPFile file
protected

◆ file_count

template<class ClientType>
int file_count = -1
protected

◆ idx

template<class ClientType>
int idx = 0
protected

◆ is_auto_next

bool is_auto_next = true
protectedinherited

◆ max_files

template<class ClientType>
size_t max_files = 0
protected

◆ p_client

template<class ClientType>
FTPClient<ClientType>* p_client = nullptr
protected

◆ p_ext

template<class ClientType>
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: