특성 값 읽기
[이 페이지와 연결된 기능인 Windows 미디어 플레이어 SDK는 레거시 기능입니다. MediaPlayer로 대체되었습니다. MediaPlayer는 Windows 10 및 Windows 11 최적화되었습니다. 가능한 경우 새 코드에서 Windows 미디어 플레이어 SDK 대신 MediaPlayer를 사용하는 것이 좋습니다. 가능한 경우 레거시 API를 사용하는 기존 코드를 다시 작성하여 새 API를 사용하도록 제안합니다.]
라이브러리 및 Windows Media 파일에서 찾을 수 있는 특성에는 미리 정의된 이름이 있습니다. 해당 특성의 이름을 Media에 전달하여 하나의 특성 값을 검색하는 코드를 작성할 수 있습니다. getItemInfo 또는 Media. getItemInfoByType. 파일 또는 항목에 있는 모든 특성의 값을 검색하는 코드를 작성할 수도 있습니다.
다음 C# 예제에서는 Title 특성의 값을 검색하여 메시지 상자에 표시합니다. 이 예제에서 Player 개체는 axWMPLib.AxWindowsMediaPlayer Player로 정의되었습니다.
IWMPMedia media;
string strAttribValue = "";
// Initialize the media object
media = Player.currentMedia;
// Retrieve the object's Title attribute
strAttribValue = media.getItemInfo("Title");
// Display the title
if (strAttribValue != "")
{
MessageBox.Show("Current title: " + strAttribValue);
}
getItemInfoByType 호출에서 두 번째 매개 변수는 언어를 지정하는 문자열입니다. 이 예제와 같이 빈 문자열을 전달하면 메서드는 기본 언어로 값을 검색합니다. 세 번째 매개 변수에 대한 자세한 내용은 여러 값이 있는 특성을 참조하세요.
다음 C# 예제에서는 현재 미디어 항목에서 지정된 특성의 값을 검색합니다. 이러한 값을 세미콜론으로 구분된 문자열로 반환합니다. WM/Lyrics_Synchronised, WM/Picture 및 WM/UserWebURL과 같은 개체로 표현되는 특성의 경우 함수는 빈 문자열을 반환합니다.
private string getAttributeValues(string strAttrName, IWMPMedia3 media)
{
string strAttrValue = "";
int iAttrCount = 0;
if (media != null)
{
// Retrieve the count of values for this attribute
iAttrCount = media.getAttributeCountByType(strAttrName, "");
// Retrieve the values
for (int i = 0; i < iAttrCount; i++)
{
strAttrValue += media.getItemInfoByType(strAttrName, "", i);
strAttrValue += ";";
}
}
// Return the resulting string
return strAttrValue;
}
getItemInfoByType 메서드에 전달된 세 번째 인수는 동일한 이름의 특성 집합에 있는 특정 특성의 인덱스입니다.
비슷한 코드를 사용하여 고유한 이름을 가진 특성을 검색할 수 있습니다. 이러한 경우 getAttributeCountByType 은 1을 반환합니다. 앞의 예제에서 getItemInfoByType 호출은 한 번만 실행됩니다.
관련 항목
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기