×

Discussion Board

Results 1 to 1 of 1

Thread: Play file

  1. #1
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    51

    Play file(updated)

    I have a file of 34MB
    Is it possible to play the file which has been obtained by two inputstream.read()? and then play the next two inputstream.read() of the file.
    Well I tried and was out of success.
    I was able to play the first two read. But when I try to play the next two read it says
    javax.microedition.media.MediaException: Malformed wave media

    Here is the code:
    Code:
    function 1:
    	HttpConnection c = (HttpConnection) Connector.open("http://localhost//test.wav"); 
    	DataInputStream response = new DataInputStream(c.openInputStream());
         byte[] buffer = new byte[100000];
    	int read = -1;
    	ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    	int times=0;
    	while ((read = response.read(buffer)) >= 0)
    	{
    	   byteout.write(buffer, 0, read);
    	  System.out.println("bytes read: " + read); 
    							
               times++;
    	   if(times==2){
    		byteout.reset();
    	   }
    	   if(times==4){
    			System.out.println("bytes stream: " + byteout.size()); 
    			laynow(byteout);
    			break;
    	   }
    							
    						
       }
    Code:
    public synchronized void playnow(ByteArrayOutputStream b){
          	  try{
                     ByteArrayInputStream is=new ByteArrayInputStream(b.toByteArray());
                                 
                     Player p2 = Manager.createPlayer(is,"audio/x-wav"); //change here while run
                      p2.prefetch();
                        p2.start();
          	  }catch(Exception e){
          	  	System.out.println(e);
          	  }
    				
          }
    Is it possible to do in this way? or do I need to chop the file and play each file sequentially.
    Last edited by csckid; 2010-09-19 at 19:40.

Similar Threads

  1. to play wmv file
    By pushpa1 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-05-14, 06:55
  2. how to play mp3 file and play long wav file
    By changsshuai in forum Symbian
    Replies: 6
    Last Post: 2008-09-02, 09:50
  3. Replies: 2
    Last Post: 2008-02-20, 08:42
  4. How can I play the segment of an audio file, e.g. wav. file in my N73?
    By ipxx in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2007-07-30, 05:03
  5. Cannot Play AMR File
    By khalandar in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2007-06-13, 11:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×