java - Access Restriction to audio -
i'm trying simple programme here can seek include on game.
package practs; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.ioexception; import java.io.inputstream; import sun.audio.*; import javax.swing.jbutton; import javax.swing.jframe; public class project1{ public static void main(string[] args){ jframe frame = new jframe(); frame.setsize(200,200); frame.setlocationrelativeto(null); jbutton button = new jbutton("click me"); frame.add(button); button.addactionlistener(new al()); frame.setvisible(true); } public static class al implements actionlistener{ public final void actionperformed(actionevent e){ music(); } } public static void music(){ audioplayer mgp = audioplayer.player; audiostream bgm; audiodata md; continousaudiodatastream loop = null; try{ inputstream test = new fileinputstream("backgroundmusic.m4a"); bgm = new audiostream(test); audioplayer.player.start(bgm); md = bgm.getdata(); loop = new continousaudiodatastream(md); }catch(filenotfoundexception e){ e.printstacktrace(); }catch(ioexception error){ error.printstacktrace(); } mgp.start(loop); } }
the problem is, errors,(except continousaudiodatastream):
access restriction: type 'audioplayer' not api (restriction on required library '/library/java/javavirtualmachines/jdk1.8.0_20.jdk/contents/home/jre/lib/rt.jar')
these errors occur
audioplayer audiostreamaudiodata
this happens continousaudiodatastream
continousaudiodatastream continousaudiodatastream cannot resolved type
the error occurs if used library not part of official jdk api. can disable these warning in eclipse preferences.
goto
windows -> preferences -> java -> compiler -> errors/warnings project -> properties -> java compiler -> errors/warnings
now goto forbidden reference (access rules)” alternative under “deprecated , restricted api
the default options set error, restricts utilize of such apis. can alter warning or ignore , clean , build code.
or can seek removing library build path , re-adding them project.
java audio restriction
No comments:
Post a Comment