示例#1
0
    def __init__(self, screen=None):
        # See if we've been given a screen to use
        if screen is None:
            self.screen = pygame.display.set_mode((600, 600))
        else:
            self.screen = screen

        self.running = True
        self.clock = pygame.time.Clock()

        # Gots to have us a background and a walkable mask
        self.background = None
        self.mask = None

        # If anyone takes screenshots, they can do so with this!
        self.screenshot_counter = 0

        # Initialize our reusable robotic girl
        self.girl = Girl()

        # What is the current state of our game
        self.state = "Running"

        # Load our music player
        self.music_player = MusicPlayer()
        self.sound_player = SoundPlayer()
        self.girl.sound_player = self.sound_player
def main(argv):

    # 1. get input file argument
    MUSICFILE = ""

    try:
        opts, args = getopt.getopt(argv,"m:",["music_file="])
    except getopt.GetoptError:
        print ('dance.py -m <filename>')
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-m':
            MUSICFILE = arg

    print("FILENAME: {}".format(MUSICFILE))
    if MUSICFILE == "":
        print("error in argument passing")
        return 1

    # 2. play
    if MUSICFILE != "bright1.mp3" and MUSICFILE != "bright2.mp3":
        print("MUSIC '{}' is not supported, or file does not exist".format(MUSICFILE))
    else:
        car, music_player = Car(), MusicPlayer()
        if MUSICFILE == "bright1.mp3":
            dance_to_bright1(car, music_player)
        if MUSICFILE == "bright2.mp3":
            dance_to_bright2(car, music_player)
    
    return 0
示例#3
0
    async def song_request(self, message):
        try:
            user_input = message.content.replace('!sr', '').strip()
            if user_input == '':
                raise NotResultsException

            song_reference = self.music_dl.download(user_input)

            if song_reference is None:
                raise NotResultsException
            song_name = self.music_dl.get_song_name(song_reference)
            await self.music_player.add_to_playlist(song_reference, message, song_name)
        except MaxDurationException as ex:
            await send_exception(message, ex)
        except NotResultsException as ex:
            await send_exception(message, ex)
        except Exception as ex:
            print('----------')
            print(ex)
            print('----------')
            # I needed to do this because only this "fix" a weird bug
            # When the player stop and then play music again the volume change to -1 and it ignore every
            # validation that I do to change it again to the initial volume
            self.music_player = MusicPlayer(os.environ.get('DOWNLOADS_PATH'))
            print(f'[Music Player Restarted at {datetime.now()}]')
            print('----------')
示例#4
0
    def __init__(
        self,
        spam_time=600,
        spam_messages=[],
        custom_rewards=[],
        tts_engine=None,
        greeting_message=''
    ):
        super().__init__(
            irc_token=os.environ.get('TMI_TOKEN'),
            client_id=os.environ.get('CLIENT_ID'),
            nick=os.environ.get('BOT_NICK'),
            prefix=os.environ.get('BOT_PREFIX'),
            initial_channels=[os.environ.get('CHANNEL')],
            client_secret=os.environ.get('CLIENT_SECRET'))

        self.user_id = os.environ.get('TWITCH_USER_ID')
        self.ignore_users = [self.nick]
        self.only_owner_commands = ['dtts', 'atts']
        self.only_mod_commands = ['vol', 'next', 'stop']
        self.owner_nick = os.environ.get('CHANNEL').replace('#', '').lower()
        self.spam_time = spam_time
        self.spam_messages = spam_messages
        self.chatters_list = []
        self.custom_rewards = custom_rewards
        self.greeting_message = greeting_message

        self.riot_api = RiotAPI()
        self.cats_api = CatsAPI()
        self.tts_engine = tts_engine
        self.music_player = MusicPlayer(os.environ.get('DOWNLOADS_PATH'))
        self.music_dl = MusicDL(download_path=os.environ.get('DOWNLOADS_PATH'))
示例#5
0
class PlayerGUI(FloatLayout):
    player = MusicPlayer()
    songs_list = ObjectProperty()
    song_time = ObjectProperty()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        directory_to_craw = input('Directory to craw for mp3 files >>>')
        self.player.load_playlist(path=directory_to_craw)
        self.songs_list.adapter.data.extend(self.player.get_all_songs_list())
        time_thread = Thread(target=self.print_curr_song_time, daemon=True)
        time_thread.start()

    def play_song(self):
        if self.songs_list.adapter.selection:
            selection = self.songs_list.adapter.data.index(
                self.songs_list.adapter.selection[0].text)
            self.player.play_song(selection)
            self.songs_list.adapter.selection[0].trigger_action()
        else:
            self.player.play_song()

    def pause_song(self):
        self.player.pause_song()

    def stop_song(self):
        self.player.stop_song()

    def print_curr_song_time(self):
        from time import sleep
        while True:
            sleep(0.75)
            self.song_time.text = self.player.get_curr_song_time()
示例#6
0
 def __init__(self, holder):
     super().__init__(holder)
     self._config = Config()
     self._player = MusicPlayer()
     self._load_alarms()
     self._time_pattern = re.compile('^([012]\d):(\d\d)$')
     self._old_time_str = ''
     self._alarm_is_playing = False
示例#7
0
 def __init__(self):
     GameState(
     )  # initialize singletons before threading to avoid race conditions
     AssetLoader()
     MusicPlayer()
     self.root = tk.Tk()
     self.windowManager = WindowManager()
     self.display = Display(self.root, self.windowManager)
     self.inputHandler = InputHandler(self.display.widget)
示例#8
0
    def __init__(self, screen=None):
        if screen is None:
            self.screen = pygame.display.set_mode((600, 600))
        else:
            self.screen = screen
        self.running = True

        self.music_player = MusicPlayer("palnap4.ogg")

        self.clock = pygame.time.Clock()

        self.choice = 0
示例#9
0
 def initAssets(self):
     AssetLoader().loadAssets()
     AssetLoader().loadSaves()
     AssetLoader().loadSettings()
     # send events for loaded settings
     if AssetLoader().getSettings() is not None:
         for setting in AssetLoader().getSettings():
             GameState().onSettingChange(setting[0], setting[1])
     else:
         MusicPlayer().playNext(AssetLoader().getMusicPath('title'))
     self.windowManager.load()
     GameState().unlockGameMode()
示例#10
0
    def __init__(self):
        self.hour = None
        self.minute = None
        self.time_window_hours = ConfigManager.get_config()['hours_to_check']
        self.time_window_minutes = ConfigManager.get_config(
        )['minutes_to_check']

        self.music_player = MusicPlayer()
        self.camera = Camera()
        self.model = Model()

        # for storing images
        self.counter = 0
示例#11
0
 def __init__(self, screen = None):
     if screen is None:
         self.screen = pygame.display.set_mode((600, 600))
     else:
         self.screen = screen
     self.running = True
     
     self.explode_anims = []
     for i in range(4):
         self.explode_anims.append(pygame.image.load(data.filepath("explode" + str(i + 1) + ".png")))
         
     self.explode_anims *= 3
     
     self.music_player = MusicPlayer("palnap4.ogg")
示例#12
0
 def test_user_login(self):
     wynk = MusicPlayer(
         10, 9, 4, 'Harshi', 'WYNK08', 'premium', ['Pachai Nirame'],
         ['descpasito'], ['Tamil', 'Hindi', 'English'], 1,
         ['Premium', 'Free', 'Subscribed'],
         ['Anirudh', 'ARR', 'Ankit Tiwari'], {
             'Anirudh': ['Yaanji', 'VIP'],
             'Dhanush': ['Maruvarthai', 'Vada chennai', 'Visiri'],
             'Hindi': ['ADHM', 'Dekthe', 'Barish']
         }, ['Nostalgic', 'Love', 'English'], [])
     song = WynkSongs('mazhai kuruvi', 'MK', 4, 'ARR', 'Tamil', 'STR',
                      'CCV', '5 mins', 'xx', 10)
     check = wynk.check_signin_name('haRsH')
     self.assertEqual(check, False)
示例#13
0
 def test_delete_songs(self):
     wynk = MusicPlayer(
         10, 9, 4, 'Harshi', 'WYNK08', 'premium', ['Pachai Nirame'],
         ['descpasito'], ['Tamil', 'Hindi', 'English'], 1,
         ['Premium', 'Free', 'Subscribed'],
         ['Anirudh', 'ARR', 'Ankit Tiwari'], {
             'Anirudh': ['Yaanji', 'VIP'],
             'Dhanush': ['Maruvarthai', 'Vada chennai', 'Visiri'],
             'Hindi': ['ADHM', 'Dekthe', 'Barish']
         }, ['Nostalgic', 'Love', 'English'], [])
     song = WynkSongs('mazhai kuruvi', 'MK', 4, 'ARR', 'Tamil', 'STR',
                      'CCV', '5 mins', 'xx', 10)
     download = wynk.delete_song('VIP')
     self.assertNotEqual(download, ['Pachai Nirame'])
示例#14
0
 def __init__(self, screen=None):
     self.cutscenes = []
     for i in range(8):
         self.cutscenes.append(pygame.image.load(data.filepath("scene" + str(i + 1) + ".png")))
     if screen is None:
         pygame.init()
         self.screen = pygame.display.set_mode((Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT))
     else:
         self.screen = screen
     self.clock = pygame.time.Clock()
     self.running = True
     
     self.font = pygame.font.Font(None, 24)
     
     self.music_player = MusicPlayer("palnap4.ogg")
示例#15
0
文件: server.py 项目: cp9ev/xiaoma
    def __init__(self):
        self.music_list = []
        self.music_player = MusicPlayer()
        self.api_map = self.init_router()

        self.start_flag = False
        self.playing_flag = False
        self.play_mode = 'loop'
        self.current_index = -1
        self.current_music = {}

        websocket_server = websockets.serve(self.service, '192.168.1.209', 8888)
        asyncio.get_event_loop().run_until_complete(websocket_server)
        asyncio.ensure_future(self.auto_next())
        asyncio.ensure_future(self.download_task())
        asyncio.get_event_loop().run_forever()
示例#16
0
    def __init__(self):
        # 0是全部列表
        self.current_menu_id = 0
        self.music_list = []
        self.music_player = MusicPlayer()
        self.album_manager = InstanceAsyncAlbumManager
        self.api_map = self.init_router()
        self.start_flag = False
        self.playing_flag = False
        self.play_mode = 'loop'
        self.current_index = -1
        self.current_music = {}

        websocket_server = websockets.serve(self.service, '0.0.0.0', 8888)
        asyncio.get_event_loop().run_until_complete(websocket_server)
        asyncio.ensure_future(self.auto_next())
        asyncio.ensure_future(self.download_task())
        asyncio.get_event_loop().run_forever()
示例#17
0
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent

        # Variable to hold the db interface object
        self.db = DB()

        # Variable holding the active extra menu below the search bar
        self.activeMenu = None

        # Variable holding the play menu
        self.playMenu = None

        # Variable for whether or not user has clicked on search bar
        self.searchActivated = False

        # Variable to hold search query
        self.searchQuery = tk.StringVar()
        self.searchQuery.set("Search library...")
        self.searchQuery.trace("w", self.parseSearch)

        # Variable to hold song name
        self.songVar = tk.StringVar()
        self.songVar.set("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW")

        # Variable to hold artist name
        self.artAlbVar = tk.StringVar()
        self.artAlbVar.set("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW")

        # Variable to hold time
        self.timeVar = tk.StringVar()
        self.timeVar.set("0:00")

        # Variable to hold total time
        self.tTimeVar = tk.StringVar()
        self.tTimeVar.set("0:00")

        # Variable to hold the music player object
        self.musicPlayer = MusicPlayer(self.songVar, self.artAlbVar, \
        self.timeVar, self.tTimeVar)

        # Configure styles
        self.style = ttk.Style(self)
        self.style.theme_use('classic')
        self.style.configure('TLabel', background='#282C34', foreground='white'\
        , font='TkFixedFont')
        # self.style.configure('Hover.TLabel', background='#808080', \
        # foreground='white') UNUSED
        self.style.configure('Small.TLabel',
                             background='#282C34',
                             foreground='white',
                             font=(None, 10))
        self.style.configure('TFrame',
                             background='#282C34',
                             font='TkFixedFont')

        # Create mainframe
        self.mainframe = ttk.Frame(self, style='TFrame')
        self.mainframe.grid(column=0, row=0, sticky='NSEW')

        # Display the main pane
        self.displayMain()
示例#18
0
    def __init__(self):
        global main
        super().__init__()
        main = self
        self.setupUi(self)

        self.submit.clicked.connect(self.on_input)
        self.data_edit.returnPressed.connect(self.submit.click)

        self.storage_manager = StorageManager()
        self.storage_manager.start()

        self.music_player = MusicPlayer()
        self.music_player.start()

        self.scheduler = Scheduler(self)
        self.scheduler.start()

        self.log_units = [
            self.storage_manager, self.music_player, self.scheduler
        ]

        self.checkbox_list = []
        for k in range(16):
            self.checkbox_list.append(getattr(self, f'checkbox_list_item{k}'))

        def get_checkbox_handler(checkbox, k, callback):
            return lambda: callback(checkbox, k)

        for k, log_unit in enumerate(self.log_units):
            self.checkbox_list[k].setText(log_unit.log_header)
            self.checkbox_list[k].setChecked(True)
            self.checkbox_list[k].toggled.connect(
                get_checkbox_handler(self.checkbox_list[k], k,
                                     self.on_toggle_checkbox))

        self.checkbox_list_autoscroll.setChecked(True)

        self.console_log = QStringListModel()
        self.console.setModel(self.console_log)

        self.schedule_tree.setHeaderLabels(['일자', '시간', '행동'])
        for head in entire_schedule:
            header = QTreeWidgetItem([head])
            for tail_time in entire_schedule[head]:
                header.addChild(
                    QTreeWidgetItem([
                        None,
                        str(tail_time), entire_schedule[head][tail_time]
                    ]))
            self.schedule_tree.addTopLevelItem(header)
            header.setExpanded(True)
        self.schedule_tree.doubleClicked.connect(
            self.on_double_click_schedule_tree)

        for k, macro_name in enumerate(quick_macros):
            create_quick_macro_button(k, macro_name, quick_macros[macro_name])

        self.log_timer = QTimer()
        self.log_timer.setInterval(1000)
        self.log_timer.timeout.connect(self.on_check_log)
        self.log_timer.start()

        self.show()
示例#19
0
 def __init__(self, **kwargs):
     super(MusicScreen, self).__init__(**kwargs)
     #self.library_manager = LibraryManager()
     self.player = MusicPlayer()
示例#20
0
文件: main.py 项目: ssahgal/pumbaa
# Copyright (c) 2016-2017, Erik Moqvist
# 
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# This file is part of the Pumbaa project.
#


from music_player import MusicPlayer

music_player = MusicPlayer()
music_player.start()
示例#21
0
async def on_message(message: Message):
    if message.author.id == bot.user.id:
        return

    control_channel = get_bot_control_channel(message.server.channels)

    if not control_channel:
        return
    if control_channel.id != message.channel.id:
        return

    if not message.content:
        await bot.delete_message(message)
        return

    content = message.content.split(' ')
    command = content[0].lower()
    if len(content) > 1:
        args = content[1:]
    else:
        args = None

    if message.channel.is_private:
        if command != 'help':
            await bot.send_message(
                message.author,
                "I didn't get that. But there are available commands:")
        await bot.send_message(message.author, help_message)

        return

    m_player = bot.music_players.get(message.server.id, None)
    user_voice_channel = message.author.voice.voice_channel
    bot_voice_channel = bot.voice_channels.get(message.server.id, None)

    if command == 'summon' or command == 'summoning jutsu':
        if user_voice_channel:
            if m_player:
                await m_player.voice_client.disconnect()
                m_player.voice_client = await bot.join_voice_channel(
                    user_voice_channel)
            else:
                voice_client = await bot.join_voice_channel(user_voice_channel)
                m_player = MusicPlayer(
                    voice_client, next_song_event_generator(control_channel),
                    settings.MUSIC_DIRECTORY, settings.DEFAULT_VOLUME)

                bot.music_players.update({message.server.id: m_player})
                bot.voice_channels.update(
                    {message.server.id: user_voice_channel})

            username = message.author.nick if message.author.nick else message.author.name
            await bot.send_message(control_channel,
                                   'At your service, sir {}.'.format(username))
        else:
            await bot.send_message(control_channel,
                                   'Unable to join: unknown voice channel!')
    elif command == 'help':
        await bot.send_message(message.author, help_message)
    elif command == 'clear_messages':
        if not message.author.permissions_in(control_channel).manage_messages:
            return
        await bot.purge_from(control_channel, limit=50)
    elif command == 'update_songs':
        if not message.author.permissions_in(control_channel).manage_messages:
            return
        m_player.update_songs()
    elif m_player and user_voice_channel == bot_voice_channel:
        if command == 'bye':
            await bot.disconnect_from_server(message.server.id)
        elif command == 'play':
            success = await m_player.play()
            if not success:
                await incorrect_message(message)
        elif command == 'seek' and args:
            await m_player.seek(args[0])
        elif command == 'volume':
            if args:
                success = m_player.set_volume(args[0])
                if not success:
                    await incorrect_message(message)
                else:
                    await bot.send_message(
                        control_channel,
                        'New volume is {}%'.format(m_player.get_volume()))
            else:
                await bot.send_message(
                    control_channel,
                    'Current volume is {}%'.format(m_player.get_volume()))
        elif command == 'pause':
            m_player.pause()
        elif command == 'stop':
            await bot.change_presence(game=discord.Game(
                name='v. {}'.format(settings.BOT_VERSION)))
            m_player.reset_player()
        elif command == 'next':
            await m_player.play_next_song()
        elif command == 'prev':
            await m_player.play_previous_song()
        elif command == 'add' and args:
            success = m_player.add_to_playlist(args[0])
            if not success:
                await incorrect_message(message)
        elif command == 'delete':
            if args:
                song = await m_player.delete_from_playlist(args[0])
            else:
                song = await m_player.delete_from_playlist()

            if not song:
                await incorrect_message(message)
            else:
                # todo: execute playlist command here
                await bot.send_message(
                    control_channel,
                    '***{}.** {} was deleted from playlist!*'.format(
                        args[0], song.title))
        elif command == 'playlist':
            plist_msg = ''
            i = 1
            for song_title in m_player.get_playlist_titles():
                if m_player.current_song_id == i - 1:
                    song_title = '**' + song_title + '**'
                else:
                    song_title = '*' + song_title + '*'

                plist_msg += '**{}**. {}\n'.format(i, song_title)
                i += 1
            if plist_msg:
                await bot.send_message(control_channel, plist_msg)
            else:
                await bot.send_message(control_channel,
                                       '*The playlist is empty!*')
        elif command == 'select' and args:
            try:
                await m_player.select_song(args[0])
            except Exception:
                await incorrect_message(message)
        else:
            await incorrect_message(message)
    else:
        await incorrect_message(message)
示例#22
0
文件: main.py 项目: Diana-Joya/Polar
import atexit
from tkinter import *
from emotion_classifier import emotion_recognition, cap
from static_ui import raise_frame, start_frame, window
from music_player import MusicPlayer
from dynamic_ui import DynamicUI
from game_state import GameState
from emotion_map import EmotionMap


if __name__ == '__main__':
    init()

    raise_frame(start_frame)
    dui = DynamicUI()
    mp = MusicPlayer()
    em = EmotionMap(dui, mp)

    e = threading.Event()
    x = threading.Thread(target=emotion_recognition, args=(e, dui))
    gs = GameState(x, e, dui, mp, em)

    start_emotion_button = Button(start_frame, text="Start Emotion Recognition", height=2,
                                  command=gs.start).grid(row=2, column=0, columnspan=2, sticky=N+S+W+E)
    quit_button = Button(start_frame, text="Exit", height=2,
                         command=gs.quit_app).grid(row=3, column=0, columnspan=2, sticky=N+S+W+E)

    gs.reset_frame()
    window.mainloop()

示例#23
0
 def __init__(self, holder):
     super().__init__(holder)
     random.seed()
     self._config = Config()
     self._player = MusicPlayer()
     self._load_config()
from helpers import get_config
from PyQt5 import QtWidgets, uic, QtGui
from PyQt5.QtCore import QThread, pyqtSignal
from threading import Thread
from music_player import MusicPlayer
import os
import json
import youtube_dl
import requests
import cv2

app = QtWidgets.QApplication([])
dialog = uic.loadUi('main.ui')
last_emotions = []

player = MusicPlayer()


def authenticate() -> ImgurClient:
    config = get_config()
    config.read('.env')
    client_id = config.get('imgur', 'client_id')
    client_secret = config.get('imgur', 'client_secret')

    return ImgurClient(client_id, client_secret)


def upload(client: ImgurClient):
    config = {
        'album': None,
        'name': 'EmotionAnalyzer!',