CD または DVD からの属性値の読み取り
[このページWindows メディア プレーヤー SDK に関連付けられている機能は、レガシ機能です。 MediaPlayer に置き換わりました。 MediaPlayer は、Windows 10とWindows 11用に最適化されています。 可能な場合は、新しいコードで SDK ではなく MediaPlayerWindows メディア プレーヤー使用することを強くお勧めします。 Microsoft は、レガシ API を使用する既存のコードを、可能であれば新しい API を使用するように書き換えるよう提案しています。]
このトピックでは、 Player オブジェクトを次の方法で定義しました。
AxWMPLib.AxWindowsMediaPlayer Player;
using WMPLib;
次の C# コード例では、ドライブ内にある現在のディスク内のすべての属性の値を取得し、ファイルに書き込みます。
private void logDiscAttributes()
{
int iCDCount = 0; // Count of CD and DVD drives
int iAttrCount = 0; // Attribute count.
int iPLCount = 0; // Playlist item count.
IWMPCdromCollection cdCollection;
IWMPPlaylist playlist;
IWMPMedia media;
string strAttribName = "";
string strAttribValue = "";
string strText = "";
// Create a StreamWriter object to write
// the output to a file.
StreamWriter sw = new StreamWriter(strOutFile, true);
cdCollection = Player.cdromCollection;
iCDCount = cdCollection.count;
// Loop through the CD and DVD drives.
for (int i = 0; i < iCDCount; i++)
{
playlist = cdCollection.Item(i).Playlist;
// Loop through the playlist attributes.
iAttrCount = playlist.attributeCount;
for (int j = 0; j < iAttrCount; j++)
{
strText += "Playlist Attribute: \t";
strAttribName = playlist.get_attributeName(j);
strText += "\t" + strAttribName + "\t";
strAttribValue = playlist.getItemInfo(strAttribName);
strText += strAttribValue + "\n";
}
// Loop through the playlist.
iPLCount = playlist.count;
for (int k = 0; k < iPLCount; k++)
{
media = playlist.get_Item(k);
// Loop through the media attributes.
iAttrCount = media.attributeCount;
for (int m = 0; m < iAttrCount; m++)
{
strText += "Track or Chapter [" + m.ToString() + "]";
strAttribName = media.getAttributeName(m);
strText += "\t" + strAttribName + "\t";
strText += "Read Only: " + media.isReadOnlyItem(strAttribName) + "\t";
strAttribValue = media.getItemInfo(strAttribName);
strText += strAttribValue + "\n";
}
}
}
sw.Write(strText);
sw.Close();
MessageBox.Show(strOutFile + " created");
}
関連トピック
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示