Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MP3 Player File Lock

807591Apr 24 2008 — edited Apr 24 2008
I am working on a program that edits the tags of an MP3. Everything works great until I edit a song that is playing with another program.

My code does the following:
Copy the MP3 while editing the tag into a temp file.
Delete the MP3
Rename it with a temp file.

Where it goes wrong:
The delete happens, but the file still plays in the player.
The rename fails.
When the song is closed by the player, the file is deleted.
Only the temp file remains.

I would like to solve this one of two ways:

1) I found that I can get an exclusive lock (FileLock) on the playing MP3. This stops the player after some seconds. I cannot figure out the next step which is to delete the locked file, and rename the temp file the same name as the locked file. I did a test. Just getting a lock does not stop the player; I was able to lock and unlock a file without interruption of the playback.

2) I would like to detect that the song in being played. That way I just don't try to edit the MP3. I can log that to the user and they can close down the player.

I realize that this is all rather high level. I am just looking for a good direction to go. Any pointers or code snippets would be great.

Edited by: solarburn on Apr 23, 2008 10:53 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 22 2008
Added on Apr 24 2008
0 comments
329 views