Skip to content
Advertisement

Can’t run a simple demo of a Media class

I found a video on YouTube about using Media class, but when I try to do it – it gives me an error. Could somebody tell me whats wrong? Here’s the code, exactly how I saw it in the video:

JavaScript

And here’s the error I get:

JavaScript

Advertisement

Answer

root.getChildren().add(root); you can’t add root to itself. Also as a simple printout can reveal, this returns null:

JavaScript

According to the documentation Media constructor expects a string in URI format, so you should use:

JavaScript

This also works:

JavaScript

Try this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement