<commit_before>'''
Audio Android MediaPlayer
===============
Implementation of Sound with the android.media.MediaPlayer
using pyjnius.
https://developer.android.com/reference/android/media/MediaPlayer.html
'''

from jnius import autoclass, PythonJavaClass, java_method
from kivy.core.audio import Sound, SoundLoader


class OnCompletionListener(PythonJavaClass):
    __javainterfaces__ = ('android.media.MediaPlayer$OnCompletionListener',)

    def __init__(self, sound):
        super(OnCompletionListener, self).__init__()
        self.sound = sound

    @java_method('(Landroid/media/MediaPlayer;)V')
    def onCompletion(self, mp):
        print 'onCompletion() called', mp
        # makes sure the sound.state gets updated
        self.sound.stop()


class SoundAndroidMp(Sound):

    @staticmethod
    def extensions():
        """
        https://developer.android.com/guide/appendix/media-formats.html
        """
        return (
                '3gp', 'mp4', 'm4a', 'aac', 'flac', 'mp3', 'mid', 'xmf',
                'mxmf', 'rtttl', 'rtx', 'ota', 'imy', 'ogg', 'wav', 'mkv',
                'webm')

    def __init__(self, **kwargs):
        MediaPlayer = autoclass('android.media.MediaPlayer')
        self._media_player = MediaPlayer()
        self.completion_listener = OnCompletionListener(self)
        self._media_player.setOnCompletionListener(self.completion_listener)
        super(SoundAndroidMp, self).__init__(**kwargs)

    def play(self):
        if self._media_player is None:
            return
        self._media_player.start()
        super(SoundAndroidMp, self).play()
<commit_msg>Update audio_androidmp.py removed debug print<commit_after>'''
Audio Android MediaPlayer
===============
Implementation of Sound with the android.media.MediaPlayer
using pyjnius.
https://developer.android.com/reference/android/media/MediaPlayer.html
'''

from jnius import autoclass, PythonJavaClass, java_method
from kivy.core.audio import Sound, SoundLoader


class OnCompletionListener(PythonJavaClass):
    __javainterfaces__ = ('android.media.MediaPlayer$OnCompletionListener',)

    def __init__(self, sound):
        super(OnCompletionListener, self).__init__()
        self.sound = sound

    @java_method('(Landroid/media/MediaPlayer;)V')
    def onCompletion(self, mp):
        # makes sure the sound.state gets updated
        self.sound.stop()


class SoundAndroidMp(Sound):

    @staticmethod
    def extensions():
        """
        https://developer.android.com/guide/appendix/media-formats.html
        """
        return (
                '3gp', 'mp4', 'm4a', 'aac', 'flac', 'mp3', 'mid', 'xmf',
                'mxmf', 'rtttl', 'rtx', 'ota', 'imy', 'ogg', 'wav', 'mkv',
                'webm')

    def __init__(self, **kwargs):
        MediaPlayer = autoclass('android.media.MediaPlayer')
        self._media_player = MediaPlayer()
        self.completion_listener = OnCompletionListener(self)
        self._media_player.setOnCompletionListener(self.completion_listener)
        super(SoundAndroidMp, self).__init__(**kwargs)

    def play(self):
        if self._media_player is None:
            return
        self._media_player.start()
        super(SoundAndroidMp, self).play()

{'fraction_non_alphanumeric': 0.13246268656716417, 'fraction_numerical': 0.0024875621890547263, 'mean_word_length': 3.167098445595855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4817270', 'n_tokens_mistral': 970, 'n_tokens_neox': 927, 'n_words': 192}