Use deezer audio preview in OGG format with on the fly conversion for Audio HTML5 Tag
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Deezer ogg preview conversion

A small script to play audio preview from deezer with html5 audio tag.

Browser :

  • Firefox
  • Chrome
  • Safari (*)
  • Internet Explorer (*)
  • Opera

(*) Works without ogg format conversion

Deezer API

Read more about Deezer API


  • ffmpeg
  • php

ffmpeg install (Debian)

sudo apt-get update
sudo apt-get install ffmpeg

Conversion Test

Try to execute this command, if you found a file named test.ogg, then you're brainy ! it works :)

 ffmpeg -i -f ogg -strict experimental -acodec vorbis -ab 192k test.ogg

How to use ?

  • Get a deezer track id from Deezer API - you can also use this wrapper for a quick start Deezer-API-PHP-Wrapper

  • Call the function getSample($track_id) or use dzpreview::getPreview($track_id) (The function calls Deezer API to get the audio preview url and directly convert it into ogg format. The ogg file will be stored in a stream folder)

  • getSample or dzpreview::getPreview($track_id) return the path of the ogg file.

Example code

 require 'class.dzpreview.php';
 $track_id = '12214510';
 $baseurl  = '';
 $path = dzpreview::getPreview($track_id);
 echo $baseurl.$path;
 //return :