Skip to content

Commit

Permalink
use pygame to play sound
Browse files Browse the repository at this point in the history
  • Loading branch information
CullenSUN committed Nov 12, 2023
1 parent a097757 commit e8805dd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mini_pupper_music/mini_pupper_music/music_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import rclpy
from rclpy.node import Node
from mini_pupper_interfaces.srv import MusicCommand
from playsound import playsound
import pygame
import threading
import os
from ament_index_python.packages import get_package_share_directory
Expand Down Expand Up @@ -61,7 +61,9 @@ def play_sound_file(self, file_name):
thread.start()

def play_sound_in_background(self, sound_path):
playsound(sound_path)
pygame.init()
pygame.mixer.music.load(sound_path)
pygame.mixer.music.play()


def main(args=None):
Expand Down

0 comments on commit e8805dd

Please sign in to comment.