<commit_before>from os.path import dirname, abspath, basename
from mycroft.audio.services import AudioBackend
from mycroft.util.log import getLogger
import vlc

logger = getLogger(abspath(__file__).split('/')[-2])


class VlcService(AudioBackend):
    def __init__(self, config, emitter=None, name='vlc'):
        self.instance = vlc.Instance()
        self.list_player = self.instance.media_list_player_new()
        self.player = self.instance.media_player_new()
        self.list_player.set_media_player(self.player)

        self.config = config
        self.emitter = emitter
        self.name = name

    def supported_uris(self):
        return ['file', 'http']

    def clear_list(self):
        empty = self.instance.media_list_new()
        self.list_player.set_media_list(empty)

    def add_list(self, tracks):
        logger.info("Track list is " + str(tracks))
        vlc_tracks = self.instance.media_list_new()
        for t in tracks:
            vlc_tracks.add_media(self.instance.media_new(t))
        self.list_player.set_media_list(vlc_tracks)

    def play(self):
        logger.info('VLCService Play')
        self.list_player.play()

    def stop(self):
        logger.info('VLCService Stop')
        self.clear_list()
        self.list_player.stop()

    def pause(self):
        self.player.set_pause(1)

    def resume(self):
        self.player.set_pause(0)

    def next(self):
        self.list_player.next()

    def previous(self):
        self.list_player.previous()

    def lower_volume(self):
        self.player.audio_set_volume(30)

    def restore_volume(self):
        self.player.audio_set_volume(100)<commit_msg>Volume is now changed in relation to current volume for vlc<commit_after>from os.path import dirname, abspath, basename
from mycroft.audio.services import AudioBackend
from mycroft.util.log import getLogger
import vlc

logger = getLogger(abspath(__file__).split('/')[-2])


class VlcService(AudioBackend):
    def __init__(self, config, emitter=None, name='vlc'):
        self.instance = vlc.Instance()
        self.list_player = self.instance.media_list_player_new()
        self.player = self.instance.media_player_new()
        self.list_player.set_media_player(self.player)

        self.config = config
        self.emitter = emitter
        self.name = name
        self.normal_volume = None

    def supported_uris(self):
        return ['file', 'http']

    def clear_list(self):
        empty = self.instance.media_list_new()
        self.list_player.set_media_list(empty)

    def add_list(self, tracks):
        logger.info("Track list is " + str(tracks))
        vlc_tracks = self.instance.media_list_new()
        for t in tracks:
            vlc_tracks.add_media(self.instance.media_new(t))
        self.list_player.set_media_list(vlc_tracks)

    def play(self):
        logger.info('VLCService Play')
        self.list_player.play()

    def stop(self):
        logger.info('VLCService Stop')
        self.clear_list()
        self.list_player.stop()

    def pause(self):
        self.player.set_pause(1)

    def resume(self):
        self.player.set_pause(0)

    def next(self):
        self.list_player.next()

    def previous(self):
        self.list_player.previous()

    def lower_volume(self):
        if self.normal_volume is None:
            self.normal_volume = self.player.audio_get_volume()
            self.player.audio_set_volume(self.normal_volume / 5)

    def restore_volume(self):
        if self.normal_volume:
            self.player.audio_set_volume(self.normal_volume)
            self.normal_volume = None
{'fraction_non_alphanumeric': 0.10741049125728559, 'fraction_numerical': 0.0033305578684429643, 'mean_word_length': 2.7777777777777777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3417680', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1106, 'n_words': 206}