Audio data type

Official Content
This documentation is valid for:

Store or reference any type of audio files (mp3, wav, etc.). An Audio-based attribute or variable can be loaded from both the FromURL method (specifying an URL, local or remote, where the audio file is stored) and setting its AudioURI property. If the value sent to FromURL is a remote URL, the audio will be downloaded and saved in the DB upon making an Insert. If what is needed is just a reference to the Audio stored in a local or remote location, the AudioURI property has to be assigned. These audios can be stored in any of the databases supported by GeneXus without having to specify its file name or extension. Therefore, any audio file can be reproduced by dragging any variable or attribute defined with the Audio data type to the form. 


AudioName   Gets the Audio name.
AudioType Gets the Audio Type. The AudioType is the extension of the audio file (e.g. mp3, wav, etc.).
AudioURL Sets or gets the Audio URL. This URL can be:
- A relative path, which will be resolved with the current host.
- An absolute path to an external audio on the web.
- A local path by using file:// protocol.
When you set the AudioURL property, the internal Blob with the audio will be set to empty.
For example,
// Example
&MyAudio.AudioURI = "http://www.myaudiofiles/audio.mp3" // audio.mp3 will be MyAudio 
On the other hand, when you want to get the value of this property, GeneXus always returns the absolute URL specified.




Loads the current audio instance (blob) with the URI indicated in the parameter. After calling this method, the AudioURI property has the absolute URL specified.

Return value: None
Parameters: AudioSource : URL

For example,

msg(&audio.AudioURI) // it will print '' text

Note: For Audio-based attributes, the audio media content will be downloaded from the URL specified and will be automatically stored in the database.


Sets the current audio-based attribute/variable to an empty value (without audio content or reference to any audio source).

Return value: None
Parameters: None


Returns True if the current audio-based attribute/variable has not a reference to a stored audio.

Return value: Boolean
Parameters: None


1. Structuring

A company wants to save songs of its bands albums; to do so, you only have to write the following:

SongId     Numeric(4.0)
SongName   Character
SongAudio  Audio

In the SongAudio field, any type of audio can be stored (mp3, wav, etc).

2. Inserting an audio into the DB from an existing URL

Suppose you have an audio file in your file system or in a web URL and you want to store it in your database. Your audio file is file:///c:/myfolder/song.mp3 (the URL must be accessible from your server if it is a local URL).

&Song.SongId = 1

3. Inserting a reference into the DB from an external audio

You want to reference an external audio, for example:  http://myband/myalbum/mysong.mp3

&Song.SongId = 1
&Song.SongAudio.AudioURI = 'http://myband/myalbum/mysong.mp3'



How to convert from Blob to Audio in your DB?

Most likely, you have many Blob attributes in your DB to store audio and you want to start using the new data type. The only thing you have to do is change the type from Blob to Audio in your attribute definition and GeneXus will perform a reorganization, taking into account the FileType, FileTypeAttribute and FileNameAttribute properties.

How to convert from Blob to Audio and vice versa programmatically?

You can directly assign a Blob to an Audio and vice versa. Remember that the conversion from Blob to Audio will work depending on the kind of mime type of your Blob and the FileType, FileTypeAttribute and FileNameAttribute properties. In some cases, it may happen that the Audio is not reproduced in the user interface.

How to convert from Char|VarChar to Audio in my DB?

In some cases, we could have a Character attribute in our DB with URL. What would happen if you wanted to start using the new Audio Data Type without losing your existing data? GeneXus supports the reorganization from Char|VarChar to Audio and vice versa.



Objects Attributes, Variables
Languages .NET, Java, Ruby
Platforms Web, Smart Devices


See also

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.