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)MusicContextzorg.renpy.android.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AndroidVideoChannel 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\androidhw.py__init__%   s"    zAndroidVideoChannel.__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_contextQ   s
    zAndroidVideoChannel.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+   r/   copyr   )r$   r-   ctxr%   r%   r&   copy_contexta   s    
z AndroidVideoChannel.copy_contextc                 C   s   | j s
dS | j d}td| tj|.}|j}t|dd}t|dd}W d   n1 s`0    Y  || _t	|||| _
dS )z>
        Starts playing the first video in the queue.
        Nr   ZPlayingbaselength)r   popprintr(   loaderloadr   getattrr   VideoPlayerr   )r$   r   fZreal_fnr3   r5   r%   r%   r&   startm   s    
*zAndroidVideoChannel.startc                 C   s$   | j d ur| j   d | _ d | _d S N)r   stopr   r$   r%   r%   r&   r?      s    

zAndroidVideoChannel.stopc                 C   s"   | j d u rd S | j  r| jS d S r>   )r   Z	isPlayingr   r@   r%   r%   r&   get_playing   s    

zAndroidVideoChannel.get_playingc                 C   s>   | j j}|r |   |   d S |  r,d S | jr:|   d S r>   )r*   
force_stopdequeuer?   rA   r   r=   )r$   rB   r%   r%   r&   periodic   s    zAndroidVideoChannel.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   )rA   r   )r$   
even_tightr%   r%   r&   rC      s    zAndroidVideoChannel.dequeuec                 C   s   |    dS )z7
        Called (mostly) once per interaction.
        N)rD   r@   r%   r%   r&   interact   s    zAndroidVideoChannel.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AndroidVideoChannel.fadeoutTr         ?c                 C   s   | j | d S r>   )r   extend)r$   	filenamesr   r   fadeintight	loop_onlyrelative_volumer%   r%   r&   enqueue   s    zAndroidVideoChannel.enqueuec                 C   s   d S r>   r%   )r$   volumer%   r%   r&   
set_volume   s    zAndroidVideoChannel.set_volumec                 C   s   d S r>   r%   r@   r%   r%   r&   get_pos   s    zAndroidVideoChannel.get_posc                 C   s   d S r>   r%   )r$   pandelayr%   r%   r&   set_pan   s    zAndroidVideoChannel.set_panc                 C   s   d S r>   r%   )r$   rR   rV   r%   r%   r&   set_secondary_volume   s    z(AndroidVideoChannel.set_secondary_volumec                 C   s   | j d ur| j   d S r>   )r   pauser@   r%   r%   r&   rY      s    
zAndroidVideoChannel.pausec                 C   s   | j d ur| j   d S r>   )r   unpauser@   r%   r%   r&   rZ      s    
zAndroidVideoChannel.unpausec                 C   s   d S r>   r%   r@   r%   r%   r&   reload   s    zAndroidVideoChannel.reloadc                 C   s   d S r>   r%   r@   r%   r%   r&   
read_video   s    zAndroidVideoChannel.read_videoc                 C   s   dS )NrE   r%   r@   r%   r%   r&   video_ready   s    zAndroidVideoChannel.video_ready)r   r   N)F)TFr   NFrJ   )__name__
__module____qualname__r'   r/   propertyr*   r2   r=   r?   rA   rD   rC   rG   rI   rQ   rS   rT   rW   rX   rY   rZ   r[   r\   r]   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(   jniusrenpy.audio.audior   	autoclassr;   objectr   r%   r%   r%   r&   <module>   s   8
