Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2013, 04:53 AM
jumpman8947 jumpman8947 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 5 jumpman8947 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 46 sec
Reputation Power: 0
Playing java songs

I'm writing a program an I've encountered a problem when trying to play music. Not getting any errors when I compile (just a few warnings like "warning: AudioPlayer is internal proprietary API and may be removed in a future release
AudioPlayer MGP = AudioPlayer.player;")
But in my program when the music is supposed to be playing it displays my error message. the wave file is in the same directory as my program, and I first tried a wav that was 25MB, that didn't work then it tried a 12KB still didn't work. Can't really figure out while its not playing. here's some of the code
Code:
import java.awt.*;
import java.io.*;
import sun.audio.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Color.*;
import javax.swing.JFrame.*;
import java.awt.EventQueue.*;

private class button3Listener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			music();
		}

	}
	public static void music()
	{
		AudioPlayer MGP = AudioPlayer.player;
		AudioStream	BGM;
		AudioData MD;
		ContinuousAudioDataStream loop = null;

		try{


		BGM = new AudioStream(new FileInputStream("bear.wav"));
		MD = BGM.getData();
		loop = new ContinuousAudioDataStream(MD);

	}catch(IOException error){JOptionPane.showMessageDialog(null, "file not found");}
	MGP.start(loop);
	JOptionPane.showMessageDialog(null, "music should be playing");
	}

Reply With Quote
  #2  
Old March 8th, 2013, 06:18 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: Eastern Florida
Posts: 2,951 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 29 m 42 sec
Reputation Power: 345
Add a call to the printStackTrace() method in the catch block so you can see what the problem is.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Playing java songs

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap