如何使用 Firemonkey 在 TMediaPlayer 中播放从 URL 加载的 .mp3 文件?
How play .mp3 files loaded from a URL in TMediaPlayer with Firemonkey?
有什么方法可以在 Delphi XE7 中使用带 Firemonkey 的 TMediaPlayer 从 URL 播放 .mp3 文件吗?此代码不起作用;
MediaPlayer1.FileName := 'http://wwww.some_site.com/some_song.mp3';
MediaPlayer1.Play;
它抛出找不到文件的异常,所以我想 TMediaPlayer 只能处理本地文件,不是吗?请提供任何帮助,将不胜感激,非常感谢。
为本地文件设置 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
类 时。
您必须实现一个以您的扩展结尾的自定义 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
(真正的 URL 不会,因此您的编解码器必须在访问 URL 之前将其删除), 例如:
MediaPlayer1.FileName := 'http://wwww.some_site.com/some_song.mp3.myext';
有什么方法可以在 Delphi XE7 中使用带 Firemonkey 的 TMediaPlayer 从 URL 播放 .mp3 文件吗?此代码不起作用;
MediaPlayer1.FileName := 'http://wwww.some_site.com/some_song.mp3';
MediaPlayer1.Play;
它抛出找不到文件的异常,所以我想 TMediaPlayer 只能处理本地文件,不是吗?请提供任何帮助,将不胜感激,非常感谢。
为本地文件设置 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
类 时。
您必须实现一个以您的扩展结尾的自定义 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
(真正的 URL 不会,因此您的编解码器必须在访问 URL 之前将其删除), 例如:
MediaPlayer1.FileName := 'http://wwww.some_site.com/some_song.mp3.myext';