<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_to_queue(self, queueable_item, position=0, as_next=False):
 """Add a queueable item to the queue. Args: queueable_item (DidlObject or MusicServiceItem):
 The item to be added to the queue position (int):
 The index (1-based) at which the URI should be added. Default is 0 (add URI at the end of the queue). as_next (bool):
 Whether this URI should be played as the next track in shuffle mode. This only works if `play_mode=SHUFFLE`. Returns: int: The index of the new item in the queue. """

        metadata = to_didl_string(queueable_item)
        response = self.avTransport.AddURIToQueue([
            ('InstanceID', 0),
            ('EnqueuedURI', queueable_item.resources[0].uri),
            ('EnqueuedURIMetaData', metadata),
            ('DesiredFirstTrackNumberEnqueued', position),
            ('EnqueueAsNext', int(as_next))
        ])
        qnumber = response['FirstTrackNumberEnqueued']
        return int(qnumber)