public static void loopSchedule(Channel channel) {

        // Shift items until the currently played item is at the top if
        // current time is between start time of first item and end time of last item
        long currentMillis = System.currentTimeMillis();
        List<ScheduleItem> schedule = channel.getSchedule();

        if (schedule != null && schedule.size() > 0 &&
                currentMillis > schedule.get(0).getStartTime() &&
                currentMillis < schedule.get(schedule.size() - 1).getStartTime() + schedule.get(schedule.size() - 1).getPlayListItem().getDuration()) {

            int currentPlaylistItemIndex = 0;
            ScheduleItem lastScheduleItem;
            long playListLength = calculatePlayListLength(channel.getPlaylist());

            for (currentPlaylistItemIndex = 0; currentPlaylistItemIndex < schedule.size(); currentPlaylistItemIndex++) {

                lastScheduleItem = schedule.get(currentPlaylistItemIndex);

                if (currentMillis >= lastScheduleItem.getStartTime() && currentMillis < lastScheduleItem.getStartTime() + lastScheduleItem.getPlayListItem().getDuration())
                    break;
            }

            for (int index = 0; index < currentPlaylistItemIndex; index++) {

                lastScheduleItem = schedule.remove(0);
                lastScheduleItem.setStartTime(lastScheduleItem.getStartTime() + playListLength);
                schedule.add(lastScheduleItem);
            }
        }

        // Set current schedule item
        if (channel.getSchedule().size() > 0) {
            channel.setCurrentItem(channel.getSchedule().get(0));
        }
    }