Stores or references 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.
||Gets the Audio name.
||Gets the Audio Type. The AudioType is the extension of the audio file (e.g. mp3, wav, etc.).
||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 AudioURI property, the internal Blob with the audio will be set to empty.
&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
msg(&audio.AudioURI) // it will print 'http://www.myband.com/song.mp3' 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
Returns True if the current audio-based attribute/variable has not a reference to a stored audio.
Return value: Boolean
A company wants to save songs of its bands albums; to do so, you only have to write the following:
In the SongAudio field, any type of audio can be stored (mp3, wav, etc).
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
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'
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.
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.
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.
||.NET, .NET Core, Java