# Play playlist item by name

**URL:** <https://community.wowza.com/t/play-playlist-item-by-name/36230>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [August 12, 2015, 3:10pm UTC](https://community.wowza.com/t/play-playlist-item-by-name/36230 "2015-08-12T15:10:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eddie\_Hermoso](https://avatars.discourse-cdn.com/v4/letter/e/dec6dc/32.png) [@Eddie\_Hermoso](https://community.wowza.com/u/Eddie_Hermoso)\
**Post date:** [August 12, 2015, 3:10pm UTC](https://community.wowza.com/t/play-playlist-item-by-name/36230/1 "2015-08-12T15:10:44Z")

</div>

I’ve created an HTTPProvider than creates and manages server-side playlists and streams. I can play a playlist item by index, but I couldn’t find a way to play it by name. Is there a method available?

Currently, I have this method that plays by index.

```auto
public void switchPlaylistItem(IApplicationInstance app, String streamName, Integer index) {
		Stream stream = (Stream)app.getProperties().getProperty(streamName);
		stream.play(index);
	}

```

Here is what my current playlist object looks like:

```auto
[{PlaylistItem: index: 0,name: "livestream",start: -2,length: -1}, {PlaylistItem: index: 1,name: "sample.mp4",start: 0,length: -1}]

```

Thanks in advance.

Eddie

---

<div class="post-metadata">

**Author:** ![Eddie\_Hermoso](https://avatars.discourse-cdn.com/v4/letter/e/dec6dc/32.png) [@Eddie\_Hermoso](https://community.wowza.com/u/Eddie_Hermoso)\
**Post date:** [August 13, 2015, 5:30pm UTC](https://community.wowza.com/t/play-playlist-item-by-name/36230/2 "2015-08-13T17:30:28Z")

</div>

Figured it out. I had to loop through the playlist items and check for the existence of a playlistitem object with that name. If so, then return the index of the object and then play that index. Here is sample code:

```auto
int index = -1;
List<PlaylistItem> items = playlist.getItems();
		for (int i = 0; i < items.size(); i++) {
			if(items.get(i).getName().equalsIgnoreCase(itemName)){
				index = items.get(i).getIndex();
				break;
			}
		}

```
