简体   繁体   English

从 axWindowsMediaPlayer 控件中检索广播歌曲标题

[英]Retrieve radio song titles from axWindowsMediaPlayer control

I am am using the AxWindowsMediaPlayer control to build a small Windows web radio developed in C# .我正在使用AxWindowsMediaPlayer控件构建在C#中开发的小型 Windows web 收音机。

在此处输入图像描述

This works out well.这效果很好。 My StatusChange event handler extracts the name of the current radio station:我的StatusChange事件处理程序提取当前广播电台的名称:

    private void axWindowsMediaPlayer1_StatusChange(object sender, EventArgs e)
    {
        IWMPMedia cm = axWindowsMediaPlayer1.currentMedia;

        if (cm != null)
        {
            title = cm.getItemInfo("Title");
        }
    }

To polish up my radio, I would like to display additional information like name and artist of the current song.为了美化我的收音机,我想显示当前歌曲的名称和艺术家等附加信息。 Such StreamTitle meta-data is shown by audio players like mpg123 .这样的StreamTitle元数据由mpg123等音频播放器显示。

Example:例子:

ICY-META: StreamTitle='Der Langmut der SPD mit Sarrazin hat nicht geholfen, Jürgen Zurheide';

Provided, a radio stream actually includes meta-information ( Icecast , SHOUTcast ):如果收音机 stream 实际上包含元信息( IcecastSHOUTcast ):

Is there a way to get hold of radio stream titles using AxWindowsMediaPlayer ?有没有办法使用AxWindowsMediaPlayer获取电台 stream 标题?

I would not like the idea of a second thread digesting the whole stream just to extract the meta-data.我不喜欢第二个线程消化整个 stream 只是为了提取元数据的想法。

There seems to be no easy way to extract SHOUTCast / Icecast meta-data from AxWindowsMediaPlayer .似乎没有简单的方法可以从AxWindowsMediaPlayer中提取SHOUTCast / Icecast元数据。

My solution is to replace AxWindowsMediaPlayer by BASS.NET .我的解决方案是用BASS.NET 替换 AxWindowsMediaPlayer

BASS is an audio library wrapped by BASS.NET for .Net usage. BASS是一个由BASS.NET包装的用于.Net使用的音频库。 It provides a TAG_INFO class which covers more than enough tags.它提供了一个TAG_INFO class 涵盖了足够多的标签。

Code snippet from a BASS C# sample NetRadio.cs来自BASS C#示例NetRadio.cs的代码片段

if ( BassTags.BASS_TAG_GetFromURL( _Stream, _tagInfo) )
{
    this.textBoxAlbum.Text = _tagInfo.album;
    this.textBoxArtist.Text = _tagInfo.artist;
    this.textBoxTitle.Text = _tagInfo.title;
    this.textBoxComment.Text = _tagInfo.comment;
    this.textBoxGenre.Text = _tagInfo.genre;
    this.textBoxYear.Text = _tagInfo.year;
}

 

Resulting radio:结果电台:

在此处输入图像描述

One alternative could be to download and evaluate status-json.xsl files provided by some internet radio stream providers.一种替代方法是下载和评估一些互联网广播 stream 提供商提供的status-json.xsl文件。 But I haven't tried this path yet.但是我还没有尝试过这条路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM