def music_setting(self, stat): response = "" try: import sys sys.path.append(self.UTILS_DIR) from musicplayer import MusicPlayer mp = MusicPlayer() player_setting = mp.get_player_setting()["status"].strip().lower() if player_setting != "close": if "pause" in stat: stat = "pause" response = "Music is Paused..." elif "skip" in stat or "next" in stat: stat = "skip" response = "Skipping..." elif "play" in stat and "stop" not in stat: stat = "Playing" response = "Now Playing..." elif "close" in stat or "stop" in stat: stat = "close" response = "Closing Music Player..." else: stat = "" if stat: mp.player_status(stat) return f'{choice(self._get_commands("acknowledge response"))} {response}' except Exception: self.Log("Music Setting Error.") return response
def __init__(self, *, playlist: list = None, loopingState: PlaylistLoopingState = PlaylistLoopingState. NotLooping): self.player = MusicPlayer() self.playlist = [] #I want it to realize its a list, none wont do that self.state = PlaylistState.Uninitialized if playlist is not None: self.playlist = playlist self.state = PlaylistState.Start self.currentIndex = 0 self.loopState = loopingState
def music_volume(self, volume): try: import sys sys.path.append(self.UTILS_DIR) from musicplayer import MusicPlayer mp = MusicPlayer() # change the directory to location of batch file to execute os.chdir(self.UTILS_DIR) mp.music_player_volume(volume) # get back to virtual assistant directory os.chdir(self.ASSISTANT_DIR) except Exception: self.Log("Music Volume Skill Error.")
def setUp(self): # creating mock discord interactions self.textChannel = AsyncMock() self.textChannel2 = AsyncMock() self.voiceChannel = AsyncMock(discord.VoiceChannel) self.voiceChannel.connect.return_value = AsyncMock(discord.VoiceClient) self.voiceChannel2 = AsyncMock(discord.VoiceChannel) self.voiceChannel2.connect.return_value = AsyncMock( discord.VoiceClient) self.client = AsyncMock() # creating mock data interactions data = {'url': 'http://mock.url', 'title': 'Mock Youtube Video'} self.ytdl = Mock() self.ytdl.extract_info = Mock(return_value=data) # creating client self.player = MusicPlayer(self.client, self.ytdl)
def restart(bus, screen): # 用于表示是否选择了卡片 bus.cardState = Constant.CARD_NOT_CLICKED # 表示选择卡片的类型 bus.cardSelection = Constant.NUT_SELECTED # 表示当前需要绘制的图片 bus.paintPlants = [] # 僵尸存储列表 bus.zombies = [] # 僵尸频率值 bus.zombieIndex = 0 # 掉头信号 bus.headFlag = True bus.zombieRate = 0 # 存放正在下落太阳的列表 bus.sunFall = [] # 存放已经停止的太阳的列表 bus.sunStay = [] for i in range(1): xx = random.randint(260, 880) yy = -random.randint(100, 300) goal = random.randint(300, 600) sun = Sun(screen, sets.sunImage, xx, yy, goal) bus.sunFall.append(sun) # 记录初始阳光数的 bus.sunScore = 100 # 初始化4个太阳 xx yy 分别记录太阳的x坐标和y坐标 # xx = [] # yy = [] # 全局统一的时间轴 bus.globalTime = 0 # 格子的二维数组 bus.gridList = [([-1] * 5) for i in range(9)] # 游戏状态 bus.state = bus.START # 子弹存储列表 bus.bullets = [] #是否进入中段和末段 bus.midPercentage = False bus.finalPercentage = False # 植物频率值 bus.plantIndex = 0 # 子弹生成频率值 bus.shootIndex = 0 # 游戏结束信号 bus.endFlag = 0 bus.music = MusicPlayer() bus.music.play()
from entity.sun import Sun from util.bus import Bus import mouseListener import painter import actioner from entity.zombie.zombie_head import Zombie_head from entity.zombie.zombie_dead import Zombie_dead from entity.plant.cherryBomb import CherryBomb import threading import time bus = Bus() sets = Setting() screen = pygame.display.set_mode((1400, 600), 0, 0) bus.music = MusicPlayer() bus.music.play() def initSun(): for i in range(1): xx = random.randint(260, 880) yy = -random.randint(100, 300) goal = random.randint(300, 600) sun = Sun(screen, sets.sunImage, xx, yy, goal) bus.sunFall.append(sun) ''' paint部分
def sound(): from musicplayer import MusicPlayer app = MusicPlayer(root)
def CreateWindow(self): music = MusicPlayer() music.player.play() windowInstance = Window()
def music_player(emotion_str): from musicplayer import MusicPlayer root = Tk() print('\nPlaying ' + emotion_str + ' songs') MusicPlayer(root, emotion_str) root.mainloop()
#logger.info('Starting the browser') # #options = Options() #options.headless = True #browser = webdriver.Firefox(options=options) browser = None # creating music player logger.info("Making music player") ytdl_format_options = { 'format': 'bestaudio/best', 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s', 'restrictfilenames': True, 'nocheckcertificate': True, 'ignoreerrors': False, 'logtostderr': False, 'quiet': True, 'no_warnings': True, 'default_search': 'auto', 'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes } ytdl = youtube_dl.YoutubeDL(ytdl_format_options) ytdl.add_default_info_extractors() mp = MusicPlayer(client, ytdl) # connecting to discord logger.warning('Connecting to discord...') client.run(token)
conf = json.load(open("conf.json")) # initialize the camera and grab a reference to the raw camera capture camera = PiCamera() camera.resolution = tuple(conf["resolution"]) camera.framerate = conf["fps"] camera.exposure_mode = "off" camera.shutter_speed = 12000 camera.awb_mode = 'auto' camera.iso = 600 camera.contrast = 50 rawCapture = PiRGBArray(camera, size=tuple(conf["resolution"])) mp = MusicPlayer() mp.connect() currentUrl = "" server = ServerConnection() # allow the camera to warmup, then initialize the average frame, last # uploaded timestamp, and frame motion counter print("[INFO] warming up...") time.sleep(conf["camera_warmup_time"]) #bg = cv2.imread("query.png") #bg = cv2.cvtColor(bg, cv2.COLOR_BGR2GRAY) #bg = cv2.GaussianBlur(imutils.resize(bg, width=320), (21, 21), 0) bg = None
def __init__(self, configFile: str): self.config = loadConfig(configFile) self.player = MusicPlayer() self.database = MusicDatabase(self.config['database']) self.playlist = Playlist() thread.start_new_thread(self.primaryThread, ())
def build(self): return MusicPlayer()
def play_music(self, voice_data): songWasFound = False option = '"play all"' shuffle = "True" mode = "compact" title = "none" artist = "none" genre = "none" response = "" try: import sys sys.path.append(self.UTILS_DIR) from musicplayer import MusicPlayer mp = MusicPlayer() # change the directory to location of batch file to execute os.chdir(self.UTILS_DIR) music_word_found = True if is_match( voice_data, ["music", "songs"]) else False meta_data = voice_data.lower().replace("&", "and").replace( "music", "").replace("songs", "").strip() if meta_data == "": # mode = "compact" alternate_responses = self._get_commands("acknowledge response") response = f"{choice(alternate_responses)} Playing all songs{', shuffled' if shuffle == 'True' else '...'}" songWasFound = True elif meta_data and "by" in meta_data.split(" ") and meta_data.find("by") > 0 and len(meta_data.split()) >= 3: option = '"play by"' by_idx = meta_data.find("by") title = meta_data[:(by_idx - 1)].strip().capitalize() artist = meta_data[(by_idx + 3):].strip().capitalize() if mp.search_song_by(title, artist, title): songWasFound = True artist = f'"{artist}"' genre = title alternate_responses = self._get_commands("acknowledge response") response = f"{choice(alternate_responses)} Playing \"{title}\" by {artist}..." else: response = f"I couldn't find \"{title}\" in your music." elif meta_data: option = '"play by"' title = f'"{meta_data}"' artist = f'"{meta_data}"' genre = f'"{meta_data}"' mp.title = meta_data mp.artist = meta_data mp.genre = meta_data if mp.search_song_by(meta_data, meta_data, meta_data): songWasFound = True alternate_responses = self._get_commands("acknowledge response") response = f"{choice(alternate_responses)} Now playing \"{meta_data.capitalize()}\" {'music...' if music_word_found else '...'}" else: response = f"I couldn't find \"{meta_data.capitalize()}\" in your music." if songWasFound: mp.player_status("close") # batch file to play some music in new window os.system( f'start cmd /k "play_some_music.bat {option} {shuffle} {mode} {title} {artist} {genre}"') # get back to virtual assistant directory os.chdir(self.ASSISTANT_DIR) return response except Exception: self.Log("Play Music Skill Error.")