Is there any way to play .mp3 files from a URL using TMediaPlayer with Firemonkey in Delphi XE7?, this code doesn't works;
MediaPlayer1.FileName := 'http://wwww.some_site.com/some_song.mp3';
MediaPlayer1.Play;
it throws an exception of File not found, so I suppose that TMediaPlayer works only with local files, isn't it?, please, any helps it would be very appreciated, thanks very much.
When setting the TMediaPlayer.FileName
property, it simply extracts the file extension from the end of the specified path (everything after, and including, the final .
character), locates a registered codec for that extension, and then tells the codec to load the FileName
value as-is. The codec returns a TMedia
object which TMediaPlayer
then uses to play/control the media as needed. By default, FireMonkey only implements TMedia
classes for local files.
You would have to implement a custom TMedia
-derived class to handle streaming media, and a custom TCustomMediaCodec
-derived class (registered for a custom file extension using TMediaCodecManager.RegisterMediaCodecClass()
) to create your TMedia
class. Then you can assign a URL to TMediaPlayer.FileName
that ends with your extension (the real URL would not, so your codec would have to strip it off before accessing the URL), eg:
MediaPlayer1.FileName := 'http://wwww.some_site.com/some_song.mp3.myext';