George David King
George David King

Reputation: 221

Loading music into pygame using tkSnack

I'm trying to load music into a python file using tkSnack Here is my code

import Tkinter as Tk
import tkSnack
root = tk.Tk()
tkSnack.initializeSnack(root)
snd = tkSnack.Sound() 
mysound.read('c:/Python27/Shingeki no Kyojin -Attack on Titan- - Opening 1, 2.mp3') 
mysound.play()

However it keeps showing me this message:

Traceback (most recent call last):
  File "C:\Users\George\Desktop\game.py", line 6, in <module>
    tkSnack.initializeSnack(root)
  File "C:\Users\George\Desktop\tkSnack.py", line 21, in initializeSnack
    Tkroot.tk.call('eval', 'package require snack')
TclError: can't find package snack

Upvotes: 0

Views: 244

Answers (1)

Vipul
Vipul

Reputation: 4168

You can use pygame.mixer.music.load("c:/Python27/Shingeki no Kyojin -Attack on Titan- - Opening 1, 2.mp3")to load your music file.

To play the music use : pygame.mixer.music.play()

also see : pygame module for controlling stream audio

Upvotes: 1

Related Questions