| Reply | « Previous Thread | Next Thread » |
|
Hello all .. let me start by saying that I am brand new to Java so the code may not be the tightest, its a bit crude, but it was the quickest way I could write the code to reporoduce the problem.
The code represents playing a clip in Java ME twice (I know that i can use the loop functionality to play 1 file twice .. but this illistrates the problem that I need to fix) its the same clip .. but this this problem is duplicated when playing trying to play any clip a second time .. even if 3 clips where played straight after it and then we try to play the first clip again... for some reason the code works perfectly on a Sony Ericsson m600i .. but running it in the N95 Emulator and on an actual device produce the same result ... Expected Result when running this code : An mp3 placed on the phone will play itself to the end and then play itself again .. Current Result : The mp3 plays once .. then generates a "File is used by other application " IOException Current Efforts to correct : have tried setting the player and fileconnection to null have tried to load a different clip and then revert back. have tried combinations of preverify,prefetch,stop,close but still NO JOY.. below is the code .. perhaps somebody can tell me how to correct this .... HEADERS : import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.io.*; import javax.microedition.io.*; import javax.microedition.io.file.*; import javax.microedition.media.*; CODE: try{ FileConnection fc = (FileConnection)Connector.open("path to file"); Player p = Manager.createPlayer (fc.openInputStream),"audio/mpeg"); p.start(); while (p.getMediaTime() < p.getDuration()){ } p.close(); fc = (FileConnection)Connector.open("path to file"); p = Manager.createPlayer(fc.openInputStream(),"audio/mpeg"); p.start(); while (p.getMediaTime() < p.getDuration()){ } fc.close(); p.close(); } catch (IOException ioe) { System.out.println(ioe.getMessage()); } catch (MediaException ME){ System.out.println(ME.getMessage()); } |
|
Try to add "fc.close();" before the first "p.close();"
|
| borje.granberg |
| View Public Profile |
| Find all posts by borje.granberg |
|
Hi,
If(p.getMediaTime() == p.getDuration()){ p.setMediaTime(0); } check whether this works..... Thanks Soku |
|
Thanks for the help guys.. have managed to fix the problem .. but it doesnt seem to get to the root cause. The problem seems to stem from the fileconnection class and not from the player.. if instead of using the fileconnection we just use the path to the file in the createplayer statement, it works perfectly.
Will implement the fixes you suggested so that perhaps we can isolate the problem and in so doing help someone else who actually has to do it with a fileconnection. Thanks again |
|
Finally understand why this was happening ... when the player is instantiated i use a fc.openInputStream() ... what needs to happen is the inputstream needs to close to release all file resources .. so a better practice would be like this
InputStream is = fc.openInputStream(); and then when finished fc.close(); is.close(); Thanks for the input guys ... much appreciated |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| please help cell id | perthachy | General Symbian C++ | 12 | 2007-07-10 14:14 |
| Carbide.vs 2.01 Registration Problem | baykal | Symbian Tools & SDKs | 5 | 2006-12-22 17:55 |
| problem with the XML Parser SyExpat | Vitaly_iva | General Symbian C++ | 2 | 2006-06-05 12:09 |
| User break point error in Grid | ag24master | Symbian User Interface | 0 | 2003-08-07 09:20 |
| Building | pacman2000z | Symbian Tools & SDKs | 0 | 2003-07-17 11:44 |