Compartilhar via


Método MediaCollection.getByName

[O recurso associado a esta página, Reprodutor Multimídia do Windows SDK, é um recurso herdado. Foi substituído pelo MediaPlayer. O MediaPlayer foi otimizado para Windows 10 e Windows 11. A Microsoft recomenda fortemente que o novo código use o MediaPlayer em vez de Reprodutor Multimídia do Windows SDK, quando possível. A Microsoft sugere que o código existente que usa as APIs herdadas seja reescrito para usar as novas APIs, se possível.]

O método getByName recupera uma playlist dos itens de mídia com o nome especificado.

Sintaxe

retVal = MediaCollection.getByName(
  name
)

Parâmetros

name [in]

Cadeia de caracteres que contém o nome.

Retornar valor

Esse método retorna um objeto Playlist .

Comentários

Para usar esse método, o acesso de leitura à biblioteca é necessário. Para obter mais informações, consulte Acesso à biblioteca.

Exemplos

O exemplo de JScript a seguir usa MediaCollection. getByName para recuperar três itens da biblioteca. Cada item é acrescentado à playlist atual. O objeto Player foi criado com ID="Player".

// In each case, use the name exactly as it appears in the library.
// Windows Media Player does not include file name extensions or file paths
// in the name. Internet URLs include the entire path, but not the 
// file name extension.

// Get a playlist object that contains an Internet URL.
var One = Player.mediaCollection.getByName("https://www.proseware.com/Media/Laure");
 
// Get a playlist object that contains a file on a network server.
var Two = Player.mediaCollection.getByName("Jeanne");

// Get a playlist object that contains a file on a local drive.
var Three = Player.mediaCollection.getByName("house");

// Append each item to the current playlist. Since each playlist retrieved
// using getByName contains one digital media item, use Playlist.item with
// an index of zero to reference that item.
Player.currentPlaylist.appendItem(One.item(0));
Player.currentPlaylist.appendItem(Two.item(0));
Player.currentPlaylist.appendItem(Three.item(0));

Requisitos

Requisito Valor
Versão
Reprodutor Multimídia do Windows versão 7.0 ou posterior.
DLL
Wmp.dll

Confira também

Objeto MediaCollection

Objeto Playlist

Settings.mediaAccessRights

Settings.requestMediaAccessRights