Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import pygame.mixer
  4. import os
  5.  
  6. from pygame.mixer import Sound
  7. pygame.mixer.quit() #Sound does not play without this line
  8. pygame.mixer.init()
  9.  
  10. try:
  11. hello = Sound(os.path.join("music","Hello.ogg"))
  12. while True:
  13. hello.play()
  14.  
  15. except:
  16. raise UserWarning, "could not load sound file"
  17.  
  18. #!/usr/bin/env python
  19.  
  20. import pygame.mixer
  21. import os
  22.  
  23. from pygame.mixer import Sound
  24. pygame.mixer.quit() #Sound does not play without this line
  25. pygame.mixer.init()
  26.  
  27. try:
  28. hello = Sound(os.path.join("music","Hello.ogg"))
  29. hello.play(0)
  30.  
  31. except:
  32. raise UserWarning, "could not load sound file"
  33.  
  34. #!/usr/bin/env python
  35.  
  36. import pygame.mixer
  37. import os
  38.  
  39. from pygame.mixer import Sound
  40. pygame.mixer.quit() #Sound does not play without this line
  41. pygame.mixer.init()
  42.  
  43. try:
  44. hello = Sound(os.path.join("music","Hello.ogg"))
  45. i = 0
  46. while (i < 3):
  47. hello.play()
  48. i = i + 1
  49. except:
  50. raise UserWarning, "could not load sound file"
  51.  
  52. time.sleep(hello.get_length())
  53.  
  54. #!/usr/bin/python
  55. import time
  56. import pygame
  57. import os
  58.  
  59. pygame_init()
  60. sound = pygame.mixer.Sound(os.path.join('music','Hello.ogg'))
  61. sound.play()
  62. time.sleep(sound.get_length())
  63.  
  64. # other initialization on top
  65.  
  66. mpg123 -q /home/pi/coolsong.mp3 &
  67. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement