Code snippet
Retrieve file column to HTML5 audio player
Copy it with the button on the code. For the why and the walkthrough, see “How to retrieve File columns using Power Pages’ Portal Web API”.
webapi.safeAjax({
type: "GET",
url: "/_api/musdyn_tracks({{ request.params.id }})/musdyn_audiotrack",
contentType:"application/json",
success: function(res) {
console.log(res);
$('#main').append('<audio controls><source src="data:audio/mp3;base64,' + res.value + '" type="audio/mpeg">Your browser does not support the audio element.</audio>');
},
error: function(xhr, status, error){
var errorMessage = xhr.status + ': ' + xhr.statusText;
console.log(errorMessage);
}
});