+ findPlaylistVideo (position: number, type: 'previous' | 'next'): VideoPlaylistElement {
+ if (
+ (type === 'next' && position > this.playlistPagination.totalItems) ||
+ (type === 'previous' && position < 1)
+ ) {
+ // End of the playlist: end the recursion if we're not in the loop mode
+ if (!this.loopPlaylist) return
+
+ // Loop mode
+ position = type === 'previous'
+ ? this.playlistPagination.totalItems
+ : 1