Author Topic: [Solved] Black Screen upon playing sounds  (Read 2238 times)

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
[Solved] Black Screen upon playing sounds
« on: Thu, Jan 20, 2011 »
Each time I try to play a sound I embedded before with:

Code: [Select]
FlxG.playMusic(SoundShoot);
I get a black screen when starting the game. (It's showing the volume options though)

How could I fix this issue?
« Last Edit: Fri, Jan 21, 2011 by Gama11 »

Backward pieS

  • Active Member
  • ***
  • Posts: 110
  • Karma: +0/-0
    • View Profile
    • Backward pieS, LLC
Re: Black Screen upon playing sounds
« Reply #1 on: Thu, Jan 20, 2011 »
In your example, it looks like your sound isn't music, so you should use "FlxG.play(SoundShoot);" instead of "playMusic." May not really be your problem, but it's good form.

If you *are* trying to play music, the problem could be that you're loading in a very large sound file. When I dropped in a long 7MB piece of temporary music, my game would start by going black until the music had finished loading. So first thing is, if you music file is huge, try trimming it shorter and make sure it is mono. Then you might want to try a couple different export settings to make sure it's properly compatible with the Flash player (I know sample rates of 44.1kHz work, but maybe someone can give us a more detailed description of acceptable sound file parameters).

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Re: Black Screen upon playing sounds
« Reply #2 on: Thu, Jan 20, 2011 »
Yeah, I just used playMusic instead of play because I wanted to try if that'd solve the issue.

Also, it's not like the game is loading the file - it even crashes my Flash Player after running a time. The file is kind of small.

And I'm pretty sure that it's compatible... I've used it in Adobe Flash CS4 before. (FD now)

Here's the embed code if that helps:

Code: [Select]
[Embed(source='../../../../med/shoot.wav', mimeType='application/octet-stream')]
   private var SoundShoot:Class;

Gold_Ninja

  • Member
  • **
  • Posts: 80
  • Karma: +0/-0
  • Yeah Yeah!! Wall Echo Saw - War  よろしくね♡
    • View Profile
Re: Black Screen upon playing sounds
« Reply #3 on: Thu, Jan 20, 2011 »
I think you can't load .wav files.  You need to convert them to mp3 format.

You can use this and this.


Hmm, maybe that's not your problem, if I use the code mimeType='application/octet-stream' then I can get my flash to load and play normally, but then it crashes when the .wav sound tries to play, so it might be something else.
« Last Edit: Thu, Jan 20, 2011 by Gold_Ninja »
- Gold_Ninja

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Black Screen upon playing sounds
« Reply #4 on: Thu, Jan 20, 2011 »
You definitely cannot embed WAV files. They have to be MP3s (and the MP3s have to be at a support bit-rate too!)

Also if you just get a black screen, are you running the Debug version of Flash Player? because embedding a wav would usually error. So the fact you didn't see the error makes me wonder if you're not running in debug? (the easy way to tell - right-click the SWF when running, do you have "Show re-draw regions" as a menu option? If not, it's not debug player)
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Gold_Ninja

  • Member
  • **
  • Posts: 80
  • Karma: +0/-0
  • Yeah Yeah!! Wall Echo Saw - War  よろしくね♡
    • View Profile
Re: Black Screen upon playing sounds
« Reply #5 on: Thu, Jan 20, 2011 »
Using mimeType='application/octet-stream' I can get my code to compile in both debug and release but I don't get the black screen problem with either, it just crashes and throws an error: "cannot convert PlayState_soundExplode1@1365521 to flash.media.Sound."

But I'm sure it should be an mp3 as you said Photon.  Convert it and try again Gama11.
« Last Edit: Thu, Jan 20, 2011 by Gold_Ninja »
- Gold_Ninja

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Black Screen upon playing sounds
« Reply #6 on: Thu, Jan 20, 2011 »
Setting the mime type like that basically says "embed this file regardless of what it is". And the compiler has done that for you. Trying to get it to play as music however and it needs to cast it to a Sound, and as such it would then die as a WAV is not a supported Flash audio type.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Re: Black Screen upon playing sounds
« Reply #7 on: Fri, Jan 21, 2011 »
Oh, ok. I thought .wav files were okay.
So I converted my sound - same issue again.

So I downloaded a file from a flixel tut, which should deinitely work - it doesn't...  :-\

Also, I don't seem the use the flash debug player. How to get FD to use it?

A quick question btw: How to use Layers in Flixel? I think there used to be something like FlxLayer, but not anymore...

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Black Screen upon playing sounds
« Reply #8 on: Fri, Jan 21, 2011 »
I think something else is erroring, but you can't tell what because you're not using the debug player.

Just download it from the Adobe site and associate it with SWF files. Then SWFs run locally will open in it.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Re: Black Screen upon playing sounds
« Reply #9 on: Fri, Jan 21, 2011 »
Thx, did that now. Now it doesn't crash, but report an error #1034.

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Black Screen upon playing sounds
« Reply #10 on: Fri, Jan 21, 2011 »
Post the FULL error here :) the line number will tell you what is triggering it.

Also are you using FlashDevelop? and if so are you compiling in Debug or Release mode? because the built-in debugger will catch all of this for you.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Re: Black Screen upon playing sounds
« Reply #11 on: Fri, Jan 21, 2011 »
Using debug mode.. The full error is German, but here you go:

Code: [Select]
TypeError: Error #1034: Typumwandlung fehlgeschlagen: de.gama11.flixelprimer::GameState_Bullet@1f55161 kann nicht in flash.media.Sound umgewandelt werden.
at org.flixel::FlxSound/loadEmbedded()[C:\Users\\Documents\flixel\ArcadeSpace\src\org\flixel\FlxSound.as:100]
at org.flixel::FlxG$/play()[C:\Users\\Documents\flixel\ArcadeSpace\src\org\flixel\FlxG.as:258]
at de.gama11.flixelprimer::GameState/create()[C:\Users\\Documents\flixel\ArcadeSpace\src\de\gama11\flixelprimer\GameState.as:35]
at org.flixel::FlxGame/switchState()[C:\Users\\Documents\flixel\ArcadeSpace\src\org\flixel\FlxGame.as:188]
at org.flixel::FlxGame/create()[C:\Users\\Documents\flixel\ArcadeSpace\src\org\flixel\FlxGame.as:477]

de.gama11.flixelprimer::GameState_Bullet@1f55161 kann nicht in flash.media.Sound umgewandelt werden basically is "can't be converted to flash.media.Sound"

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Black Screen upon playing sounds
« Reply #12 on: Fri, Jan 21, 2011 »
Upload the mp3 you are using somewhere. The error basically says it's not a valid mp3.
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Re: Black Screen upon playing sounds
« Reply #13 on: Fri, Jan 21, 2011 »
Ok.. Well, I tried a lot of different mp3's, even that one from the flixel tut didn't work. There it is:

http://www.file-upload.net/download-3148684/Bullet.mp3.html

photonstorm

  • Administrator
  • Key Contributor
  • *****
  • Posts: 1502
  • Karma: +1/-0
    • View Profile
    • Photon Storm
Re: Black Screen upon playing sounds
« Reply #14 on: Fri, Jan 21, 2011 »
You are compiling for Flash Player 10, yes?
http://www.photonstorm.com



"Tell me and I will forget, show me and I might remember, involve me and I will understand" - Confucius

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Re: Black Screen upon playing sounds
« Reply #15 on: Fri, Jan 21, 2011 »
10.1 even, I think.

Edit:
Nvm, I found the reason for the problem. (By asking someone on Kong) It works fine when I remove this:

Code: [Select]
mimeType='application/octet-stream
« Last Edit: Fri, Jan 21, 2011 by Gama11 »