Java Mp3 Player

0 views
Skip to first unread message

Jeff

unread,
Aug 3, 2024, 4:52:56 PM8/3/24
to loriregen

I am evaluating libraries for playing audio/video in Java. It does not need to be 100% Java; Java bindings to native libraries are perfectly OK. An external application that can be controlled from Java is also fine, as long as it can render video on a Java component.

I have played with VLC using the VLCj bindings, and it works pretty well in general, but keeps crashing occasionally when put under stress. I have also used mplayer in slave mode, which looks good. But I'd like to evaluate other options as well.

VLC. This was my first thought, as everybody keeps saying that it "plays everything". I have used both the VLCj Java bindings, and the built-in remote interface (-I rc). I found this to work pretty well in general, but had some issues. I kept seeing ocassional crashes under heavy load (not VLCj's fault as it also happens when using the binary directly). Also I've found memory consumption to be relatively high when compared to other options.

I've also spent a while researching my options, and I've actually come to the conclusion that VLCJ is the best option - however here's the clincher, you need to run it out of process (especially with multiple players) for it to give you 100% reliable operation. That's the approach I'm taking and I've yet to see it crash. With it rock solid in this way it also has other advantages:

I haven't found it that heavy on the resources front either, though I haven't done any thorough testing (but 3 players work fine in tandem as well as my relatively power-hungry application on my 4 year old basic laptop!)

Disadvantages? There's no official framework for out of process players, so you have to build one yourself (see here for how I did it). And you do sometimes have to do some fiddling to get it working. But as far as I can see, it's working well for me so far!

Unfortunately, I have no experience with C#, COM or ActiveX. I need someone to translate this code to C++, allowing me to embed the Flash Player into a Win32 Window. Ultimately I'd like to use this information to embed Flash into a Java application.

I don't know how to embed flash in C++, but Christopher Deckers (of SWTSwing fame) has developed an interesting hack which allows it to be embedded in Java. You can find more information in the Javalobby announcement thread.

If it has to be open source I'd consider Gnash, an open source flash implementation.
It works on all major platforms, supports most multimedia codecs and is supposed to be embeddable in applications through nsapi.

Your app should check at runtime for flash player and should alert the user if it doesn't find it (usually by giving a link to Adobe to download it).Flashplayer plugin is usually installed at %AppData%\Mozilla\plugins on Windows.

I personally haven't tried this but say in case of SWT/Java you could embed SWT browser window in you SWT/Java application and in the browser view you could put content with flash content, then communicate say with Merapi bridge with flash movie and java.

However, how do I make sure that the Human and the Computer take it in turns to play on my main method? If i run this code currently, it only allows player 1 to play until theyve won, then moves onto the computer.

I took a different approach, and added my code to a public github repo. In Summary, I created objects for BoardPositions, created an Interface for Player with two classes that implement it, Human Player and Computer Player. The Player interface has a method makeMove() and in the human player implementation it will sysout, sysin to get the value. For the Computer Player I created a abstract class called ComputerStrategy, that allows multiple computer strategies to be implemented and the computer player makeMove method delegates to the strategy. I also created a GameController that is instantiated in the Main method of the Main class and it allows you to setup the game by asking how many human players (then the name of each human player) and how many computer players. I also made each human player pick a unique character that represents their pieces on the board.

Its not fully implemented, the logic that checks for a winner needs to be added, the controller also randomizes the player order and it needs a loop to for player turns until the game board is full with no winner or a winner is found.

For the computer strategies, my idea was to start simple by just blocking any potential winning move, I made ComputerStrategy an abstract class because it should have helper methods like if there is a potential next winning move and if so return the column.

Move your game loop while in your main function, otherwise it is waiting for the game to end in HumanPlayer.getUserInput(). Also, you should add a function that verifies if either player has won, because it doesn't match the definition of getUserInput.

Right, i am working on a new 2d/top down Java game. Recently, i have been teaching myself how to code in Java however i do have one problem... I have a box in my window which i am able to move around with the W,A,S AND D keys. All i want to know is how to replace that black box with an image(then later worry about animations). Here is my code (btw, this code is also the game engine).Also here is the image that i am trying to add Player image

All of this information I got from Oracle's documentation. Give their documentation a search next time before asking, you'll find that just about anything you're having trouble with is extensively covered! Also, this question has been asked numerous times, so googling stackoverflow paint image java should give you some quick answers.

Alright, so in my game I have a class for the player (with the parameters of x, y, color, width, height, and health, same parameters with the enemy). But I have a problem. So, in my player class, I have a draw method which sets the color and fills a rectangle with the variables specified in the parameters. In my main class, I create an instance of that player, and call the draw method from there, too. However, when I try to create more than 1 player object, it just renders the second one, rather than both, even if the x, y, color, and pretty much everything is different.

This is most likely because to make more than one instance of this you will need an array of these objects. Usually there would only be one player and multiple enemies so the player would be a single object and the enemies an array. Here's do simple code to explain this:

Kurento is a low-level platform to create WebRTC applications from scratch. You will be responsible of managing STUN/TURN servers, networking, scalability, etc. If you are new to WebRTC, we recommend using OpenVidu instead.

To implement this behavior we have to create a Media Pipeline composedby one PlayerEndpoint and one WebRtcEndpoint. The PlayerEnpdointplays a video and WebRtcEndpoint shows it.

This is a web application, and therefore it follows a client-serverarchitecture. At the client-side, the logic is implemented in JavaScript.At the server-side, we use a Spring-Boot based application server consuming theKurento Java Client API, to control Kurento Media Server capabilities.All in all, the high level architecture of this demo is three-tier. Tocommunicate these entities, two WebSockets are used. First, a WebSocket iscreated between client and application server to implement a custom signalingprotocol. Second, another WebSocket is used to perform the communicationbetween the Kurento Java Client and the Kurento Media Server. Thiscommunication takes place using the Kurento Protocol. For furtherinformation on it, please see thispage of the documentation.

This demo has been developed using Java in the server-side, based on theSpring Boot framework, which embeds a Tomcat web server within thegenerated maven artifact, and thus simplifies the development and deploymentprocess.

You can use whatever Java server side technology you prefer to build webapplications with Kurento. For example, a pure Java EE application, SIPServlets, Play, Vert.x, etc. Here we chose Spring Boot for convenience.

This web application follows a Single Page Application architecture(SPA), and uses a WebSocket to communicate client withapplication server by means of requests and responses. Specifically, the mainapp class implements the interface WebSocketConfigurer to register aWebSocketHandler to process WebSocket requests in the path /player.

PlayerHandlerclass implements TextWebSocketHandler to handle text WebSocket requests.The central piece of this class is the method handleTextMessage. Thismethod implements the actions for requests, returning responses through theWebSocket. In other words, it implements the server part of the signalingprotocol depicted in the previous sequence diagram.

In the designed protocol, there are seven different kinds of incoming messagesto the Server : start, stop, pause, resume, doSeek,getPosition and onIceCandidates. These messages are treated in theswitch clause, taking the proper steps in each case.

In the following snippet, we can see the start method. It handles the ICEcandidates gathering, creates a Media Pipeline, creates the Media Elements(WebRtcEndpoint and PlayerEndpoint) and makes the connections betweenthem and plays the video. A startResponse message is sent back to theclient with the SDP answer. When the MediaConnected event is received, infoabout the video is retrieved and sent back to the client in a videoInfomessage.

These libraries are linked in theindex.htmlweb page, and are used in theindex.js.In the following snippet we can see the creation of the WebSocket (variablews) in the path /player. Then, the onmessage listener of theWebSocket is used to implement the JSON signaling protocol in the client-side.Notice that there are seven incoming messages to client: startResponse,playEnd, error, videoInfo, seek, position andiceCandidate. Convenient actions are taken to implement each step in thecommunication. For example, in functions start the functionWebRtcPeer.WebRtcPeerSendrecv of kurento-utils.js is used to start aWebRTC communication.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages