Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: When I try to play music from another class I get an error, help please?  (Read 2085 times)

0 Members and 1 Guest are viewing this topic.

MarcuzPwnz

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
When I try to play music from another class I get an error.

I have the music defined in my second class under public and have just been using SecondClass.button_click.play(); in my main class to play the music. (button_click is the name of the music I'm trying to play.)

The error I get is:
"Failed to play audio stream: sound parameters have not been initialized (call Initialize first)"

I tried calling the initialize() function on button_click but initialize() is a protected member of the Music class so obviously I can't. :(

Any ideas on how I could fix this?
« Last Edit: February 06, 2013, 08:53:08 am by MarcuzPwnz »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Quick question. :)
« Reply #1 on: February 06, 2013, 08:12:13 am »
Did you first open a music file to play?
Laurent Gomila - SFML developer

MarcuzPwnz

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: Quick question. :)
« Reply #2 on: February 06, 2013, 08:40:37 am »
Did you first open a music file to play?

Yes of course. :P

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Quick question. :)
« Reply #3 on: February 06, 2013, 08:47:32 am »
So you should provide a complete and minimal code that reproduces the problem.

And please, edit the title of the topic. Everyone here has a "quick question" to ask, it doesn't help at all to name a topic like this.
Laurent Gomila - SFML developer

MarcuzPwnz

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: When I try to play music from another class I get an error, help please?
« Reply #4 on: February 06, 2013, 09:09:48 am »
Well I feel really stupid now.

I wasn't calling the setMusic() function that opens the file to play.

Sorry to bother you.  :-X