JavaFX - Media("File://derp") terminates with exception: MEDIA_INNACCESSIBLE - java

I'm trying to get a simple mp3 to run while my program runs, through this:
Media med = new Media("file://C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
MediaPlayer mPlayer = new MediaPlayer(med);
mPlayer.play();
But I'm running into problems. Running the program terminates with exception Exception in thread "main" MediaException: MEDIA_INACCESSIBLE : C, with reference to the first line of the code segment above, the one calling the Media() constructor.
I've had no previous experience with javafx or playing media in code, would anyone have any idea on why it would deem the file inaccessible? Am I doing anything simple incorrectly?
The file is, of course, fine. I can open it in a myriad different media players and it's fine.

This way it will work:
Media med = new Media("file:///C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
Note 3 slashes after file:.
Here is why: https://superuser.com/questions/352133/what-is-the-reason-that-file-urls-start-with-three-slashes-file-etc

Related

LibGDX RayHandler: Cannot use offsets when Pixel Unpack Buffer Object is disabled

I recently updated my LibGDX library used in my game by using the LibGDX setup program to create a new project, then importing all of my classes, assets, etc into said new project. Everything went fine, the game runs and I can get in to the main menu. However, when I try advancing to the game where I have Box2DLights, I get an error thrown on the instantiation of my RayHandler. The RayHandler is instantiated like so:
rays = new RayHandler(world, Game.V_WIDTH/LIGHT_PIXEL_SIZE, Game.V_HEIGHT/LIGHT_PIXEL_SIZE);
This worked In the older version of the LibGDX libraries but now it throws Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled
The old version of LibGDX had GL20 and this one has GL30. I'm not sure if this is relevant because I have little to no knowledge of OpenGL.
Putting the line Gdx.gl.glBindBuffer(GL30.GL_PIXEL_UNPACK_BUFFER, 1); before the instantiation of my RayHandler changed the error to Exception in thread "LWJGL Application" java.lang.IllegalStateException: Frame buffer couldn't be constructed: incomplete attachment. Thrown on the line where my RayHandler is instantiated again.
The entire relevant stack trace for the first error is:
Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled
at org.lwjgl.opengl.GLChecks.ensureUnpackPBOenabled(GLChecks.java:125)
at org.lwjgl.opengl.GL11.glTexImage2D(GL11.java:2899)
at com.badlogic.gdx.backends.lwjgl.LwjglGL20.glTexImage2D(LwjglGL20.java:598)
at com.badlogic.gdx.graphics.glutils.GLOnlyTextureData.consumeCustomData(GLOnlyTextureData.java:78)
at com.badlogic.gdx.graphics.GLTexture.uploadImageData(GLTexture.java:270)
at com.badlogic.gdx.graphics.GLTexture.uploadImageData(GLTexture.java:257)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:159)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:147)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:142)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.createTexture(FrameBuffer.java:81)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.createTexture(FrameBuffer.java:42)
at com.badlogic.gdx.graphics.glutils.GLFrameBuffer.build(GLFrameBuffer.java:174)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.<init>(FrameBuffer.java:75)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.<init>(FrameBuffer.java:57)
at box2dLight.LightMap.<init>(LightMap.java:118)
at box2dLight.RayHandler.resizeFBO(RayHandler.java:143)
at box2dLight.RayHandler.<init>(RayHandler.java:132)
My question was answered by someone in the LibGDX Discord server. They shared this with me: https://github.com/libgdx/libgdx/issues/6407
Who knew that there could be a bug that isn't my fault?
Changing the GDX version from 1.9.14 to 1.9.15-SNAPSHOT fixed the issue.

Mallet HierarchicalLDATUI throws NullPointerException for certain files

In the past few days, I have started using Mallet. I am specifically interested in running a hierarchical topic model, like HLDA or HPAM. When importing the sample data files and running them using the cc.mallet.topics.tui.HierarchicalLDATUI class, I get results, no problems.
When running the same on the Wikipedia article on WW2, after importing I get the following error:
$ bin/mallet run cc.mallet.topics.tui.HierarchicalLDATUI --input ww2.mallet
Exception in thread "main" java.lang.NullPointerException
at cc.mallet.topics.HierarchicalLDA$NCRPNode.dropPath(HierarchicalLDA.java:637)
at cc.mallet.topics.HierarchicalLDA.samplePath(HierarchicalLDA.java:164)
at cc.mallet.topics.HierarchicalLDA.estimate(HierarchicalLDA.java:133)
at cc.mallet.topics.tui.HierarchicalLDATUI.main(HierarchicalLDATUI.java:109)
I imported the data like this:
$ bin/mallet import-dir --input ww2Wiki --output ww2.mallet --keep-sequence TRUE --skip-html TRUE --remove-stopwords TRUE
To make your lives easier, here's the code at which the error occurs in HierarchicalLDA.java (lines 627-640)
public void dropPath() {
NCRPNode node = this;
node.customers--;
if (node.customers == 0) {
node.parent.remove(node);
}
for (int l = 1; l < numLevels; l++) {
node = node.parent;
node.customers--;
if (node.customers == 0) {
node.parent.remove(node); //line 637 (producing the error)
}
}
}
Seemingly, the error occurs when, during the NCRP implementation, it tries to remove a node, which is null. I do not know why this happens with certain files but not with others.
I checked if it might be a general problem related to the file running the same file on cc.mallet.topics.HierarchicalPAM and with that the file works and HPAM produces reasonable results. Other files work in the HLDA implementation, so I do not think it is the code itself.
At this point I am clueless what to do. Did anyone encounter and solve this problem before?
Thanks!
PS: I feel like I have to point this out for the Java community. This is not my code, it is an open source software, which I compiled on my computer. I am missing both time and overview to read through the whole code to track down the error.
It took a while but I found the answer to the problem and it seems too simple.
HLDATUI considers files as documents, which means if there is only one file there are not enough documents and the program crashes. That means one has to import more than one file.
The solution to my personal situation is that I will write a program, which will split the .xml file I want to run HLDATUI on into multiple smaller files, which then can be imported and analyzed.

Error NullPointer Neuroph doOneLearningIteration

I'm using Neuroph 2.9 framework to code ANN to predict housing prices. I want get every error every time run every epoch (to show the improve of error on chart) but this cause error.
// create multi layer perceptron
System.out.println("Creating neural network");
MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(
TransferFunctionType.SIGMOID, inputsCount, hiddentsCount1,
outputsCount);
// set learning parameters
MomentumBackpropagation learningRule = new MomentumBackpropagation();
learningRule.setLearningRate(0.3);
learningRule.setMomentum(0.5);
learningRule.setNeuralNetwork(neuralNet);
learningRule.setTrainingSet(TrainSet);
learningRule.doOneLearningIteration(TrainSet);
I get this:
Exception in thread "main" java.lang.NullPointerException
at org.neuroph.nnet.learning.MomentumBackpropagation.updateNeuronWeights(MomentumBackpropagation.java:72)
at org.neuroph.nnet.learning.BackPropagation.calculateErrorAndUpdateOutputNeurons(BackPropagation.java:83)
at org.neuroph.nnet.learning.BackPropagation.updateNetworkWeights(BackPropagation.java:53)
at org.neuroph.core.learning.SupervisedLearning.learnPattern(SupervisedLearning.java:190)
at org.neuroph.core.learning.SupervisedLearning.doLearningEpoch(SupervisedLearning.java:165)
at org.neuroph.core.learning.IterativeLearning.doOneLearningIteration(IterativeLearning.java:245)
at com.thao.Main.main(Main.java:76)
The problem is when I use : learningRule.learn(TrainSet); it's ok, no error come out. The documentation so bad to differ functions to chose right function to run the right thing I want.
The thing I found is that doOneLearningIteration function didn't work because inside them. It's not initiated. Therefore, to run, we need to override or run 1 epoch and then doOneLearningIteration.
That's work for me.

JTwitter : getStatus()

I'm creating a desktop Twitter client in Java and I'm using JTwitter.
I tested a few lines of code with this library, which seems good, but I'm stuck at one point.
When running my app, Eclipse prints :
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at winterwell.jtwitter.InternalUtils.asMap(InternalUtils.java:170)
at winterwell.jtwitter.Twitter.getStatus(Twitter.java:1646)
at Twittshader.main(Twittshader.java:34)
If you want to see the code (oauthClient and twitter objects are declared, I don't think the problem comes from these) :
oauthClient.authorizeDesktop();
String v = oauthClient.askUser("Please enter the verification PIN from Twitter");causes that.
oauthClient.setAuthorizationCode(v);
String[] accessToken = oauthClient.getAccessToken();
// Works through all the program but crashes at this point
System.out.println(twitter.getStatus("ShadeosIsaac"));
twitter.setStatus("Running some tests");
I really don't know why it is crashing. I'm pretty sure it is quite a simple thing, but I'm not sure what to do. Ideas ?
Can I ask: What version of the JTwitter jar do you have?
You can find this with: System.out.println(Twitter.version);

RXTXComm. Not correct Eclipse behaviour during read from stream []byte

I' creating application that reads/writes to/from com port using RXTXComm library. When I'm trying to read one byte from stream everything goes fine.
while ( ( data = in.read() ) > -1 )
Then I tried to read []byte and put breakpoint to this line:
int g = in.read(buffer,off,len);
When debug reaches this place and I do resume debug - new window with message described bellow appears:
Class File Editor
Source not found
----------------------
The JAR file c:\pro\RXTXcom.jar has no source attachment.
You can attach the source by clicking Attach Source below:
What is the problem? This is not exception, because I can't catch it in try-except block. What is this? I didn't asked for "trace in" and I don't need source.
It appears that your IDE (which you do not name) is telling you it is trying to display a line from the RXTXcom library, but it has no source code to use to do so. I would expect this if I were using eclipse, had a binary-only copy of the library, exception checking turned on in the debugger, and the library threw an exception.
I don't recognize "resume debug - new window", so I don't know what effect that might have.
Eclipse has a "step out" function in its debugger, allowing you to step through the next return statement; that might help you get to a level for which you do have source.
I doubt this message has much to do with your actual 1 byte vs. byte array reading problem.

Categories