a
    V$c                     @   s   d dl mZmZmZmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZ d dlZd dlZd dlmZ edZG dd deZdS )    )divisionabsolute_importwith_statementprint_functionunicode_literals)PY2
basestringbchrbordchropenpystrrangeroundstrtobytesunicodeN)MusicContextVideoPlayerc                   @   s   e Zd Zd/ddZdd ZeeZdd Zd	d
 Zdd Z	dd Z
dd Zd0ddZdd Zdd Zd1ddZdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. ZdS )2IOSVideoChannel Nc                 C   sn   g | _ d | _d | _|| _d | _d| _d | _d| _d| _g | _	|| _
|| _|d u r^d| _d| _n|| _d| _d S )Nr   FT)queuefilenameplayernamemixerlast_changedcallbacksynchro_start	wait_stoploopfile_prefixfile_suffixdefault_loopdefault_loop_set)selfr   r!   r"   r#    r&   renpy/audio\ioshw.py__init__   s"    zIOSVideoChannel.__init__c                 C   s4   t j j}|| j}|du r0t  }|| j< |S )z
        Returns the MusicContext corresponding to this channel, taken from
        the context object. Allocates a MusicContext if none exists.
        N)renpygamecontextmusicgetr   r   )r%   mcdrvr&   r&   r'   get_context<   s
    zIOSVideoChannel.get_contextc                 C   s&   t j j}|   }||| j< |S )z
        Copies the MusicContext associated with this channel, updates the
        ExecutionContext to point to the copy, and returns the copy.
        )r)   r*   r+   r,   r0   copyr   )r%   r.   ctxr&   r&   r'   copy_contextL   s    
zIOSVideoChannel.copy_contextc                 C   sb   | j s
dS | j d}tj|}|j}W d   n1 s>0    Y  || _t 	|| _
dS )z>
        Starts playing the first video in the queue.
        Nr   )r   popr)   loaderloadr   r   r   allocZinitWithFile_r   )r%   r   fZreal_fnr&   r&   r'   startX   s    $zIOSVideoChannel.startc                 C   s$   | j d ur| j   d | _ d | _d S N)r   stopr   r%   r&   r&   r'   r;   g   s    

zIOSVideoChannel.stopc                 C   s"   | j d u rd S | j  r| jS d S r:   )r   Z	isPlayingr   r<   r&   r&   r'   get_playingo   s    

zIOSVideoChannel.get_playingc                 C   sN   | j j}|r |   |   d S | jr0| j  |  r<d S | jrJ|   d S r:   )	r+   
force_stopdequeuer;   r   periodicr=   r   r9   )r%   r>   r&   r&   r'   r@   w   s    
zIOSVideoChannel.periodicFc                 C   s$   |   rg | _n| jdd | _dS )ze
        Clears the queued music, except for a first item that has
        not been started.
        N   )r=   r   )r%   
even_tightr&   r&   r'   r?      s    zIOSVideoChannel.dequeuec                 C   s   |    dS )z7
        Called (mostly) once per interaction.
        N)r@   r<   r&   r&   r'   interact   s    zIOSVideoChannel.interactc                 C   s   |    g | _dS )z
        Causes the playing music to be faded out for the given number
        of seconds. Also clears any queued music.
        N)r;   r   )r%   secsr&   r&   r'   fadeout   s    zIOSVideoChannel.fadeoutTr         ?c                 C   s   | j | d S r:   )r   extend)r%   	filenamesr    r   fadeintight	loop_onlyrelative_volumer&   r&   r'   enqueue   s    zIOSVideoChannel.enqueuec                 C   s   | j d ur| j   d S r:   )r   pauser<   r&   r&   r'   rN      s    

zIOSVideoChannel.pausec                 C   s   | j d ur| j   d S r:   )r   unpauser<   r&   r&   r'   rO      s    

zIOSVideoChannel.unpausec                 C   s   d S r:   r&   )r%   volumer&   r&   r'   
set_volume   s    zIOSVideoChannel.set_volumec                 C   s   d S r:   r&   r<   r&   r&   r'   get_pos   s    zIOSVideoChannel.get_posc                 C   s   d S r:   r&   )r%   pandelayr&   r&   r'   set_pan   s    zIOSVideoChannel.set_panc                 C   s   d S r:   r&   )r%   rP   rT   r&   r&   r'   set_secondary_volume   s    z$IOSVideoChannel.set_secondary_volumec                 C   s   d S r:   r&   r<   r&   r&   r'   reload   s    zIOSVideoChannel.reloadc                 C   s   d S r:   r&   r<   r&   r&   r'   
read_video   s    zIOSVideoChannel.read_videoc                 C   s   dS )NrA   r&   r<   r&   r&   r'   video_ready   s    zIOSVideoChannel.video_ready)r   r   N)F)TFr   NFrF   )__name__
__module____qualname__r(   r0   propertyr+   r3   r9   r;   r=   r@   r?   rC   rE   rM   rN   rO   rQ   rR   rU   rV   rW   rX   rY   r&   r&   r&   r'   r      s*   
,
	
r   )
__future__r   r   r   r   r   renpy.compatr   r   r	   r
   r   r   r   r   r   r   r   r   r)   pyobjusrenpy.audio.audior   	autoclassr   objectr   r&   r&   r&   r'   <module>   s   8
