×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    32

    Exclamation Please its veru urgent on nokia 3250

    Hello all,
    we have one samll application, which downloads a mp4 song and plays it simultaneously. but the problem here is we r able to acheive the output on 3rd edition emulator but when we install it on nokia 3250 it doesn't have that continuous playing.

    the logic we r applying is we r creating a httpconnection to download the file and after that we r going for a fileconnection and an outputstream to write in to this file.

    we r dividing the httpconnection stream in to 8 parts and writing in to file in a while loop and takingg up the file as and when it writes the first part in to it and play it.

    but when we deply it on 3250 it plays first chunk properly but not the subsequent writings. its not even able to identify the ENDOFMEDIA.

    is anyone having any solution pls
    pls
    pls
    write back to me.
    its very urgent
    with rgs
    siva.

  2. #2
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: Please its veru urgent on nokia 3250

    hi,

    check ur code after playing the first chunk

    try to check whether the play is Stopped with the StopL function and continue playing the file after each file playing ends.

    Regards,
    Mateen maldar

  3. #3
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Please its veru urgent on nokia 3250

    Hi siva,
    Have you implemented the playerListener interface.If so once playback is over,then the event STOPPED will also be returned along with the ENDOFMEDIA.if u can post that part of the code we can sort ouit the problem.

    Thanks
    Soku

  4. #4
    Super Contributor
    Join Date
    Mar 2006
    Posts
    516

    Re: Please its veru urgent on nokia 3250

    Hi,

    It may also be due to the problem that the the rest of the parts of the sound file got corrupted.
    Please post the code so that it will be help to us to find out what had gone wrong.


    Wang

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    32

    Exclamation Re: Please its veru urgent on nokia 3250

    hi,
    as u said, i am posting the code here
    pls help me in solving this problem.
    with rgs

    Code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import javax.microedition.media.control.MetaDataControl;
    import javax.microedition.io.*;
    import javax.microedition.io.file.*;
    import java.util.*;
    import java.io.*;
    
    public class StreamingAudio1 extends MIDlet implements PlayerListener, Runnable, CommandListener
    {
    	Thread t;
    	Command exit,select, back;	
    	List status = new List("Status",List.IMPLICIT);
    	List songs = new List("Select Song", List.IMPLICIT);
    	Display disp;
    	FileConnection filecon = null, log = null;
    	OutputStream os = null;
    	InputStream is = null;
    	InputStream is1 = null;
    	HttpConnection con = null;
    	int length = 0;
    	int totalsize = 0;
    	int j = 0, i = 0;
    	byte[] chunk;
    	boolean play = false, Once = false,end = false,interrupted = false;
        Player player;
        int action = 0;
    	long startTime = 0;
    	int chunkCount = 0;
    	int runAction = 0;
    	String event = "";
    	String[] keys;
    	public void startApp() 
        {
        	try
        	{
    			createFolder();
    			exit = new Command("Exit",Command.EXIT,1);
    			select = new Command("Select",Command.EXIT,1);
    			back = new Command("Back",Command.BACK,1);
    			songs.append("Dus-Bahaane.mp3", null);
    			songs.append("Dus-Bahaane.mp4", null);
    			songs.append("Dus-Bahaane.3gp", null);
    			songs.addCommand(select);
    			songs.setCommandListener(this);
    			status.addCommand(exit);
    			status.addCommand(back);
    			status.setCommandListener(this);
    			disp = Display.getDisplay(this);
    			disp.setCurrent(songs);
    			status.append("Loading:", null);
    		}
        	catch(Exception e)
        	{	
        		System.out.println("Exception in start app: "+e);
    			writeLog("SA"+e);
    			status.append("SA: "+e+":", null);
        	}
        }
        public void pauseApp() 
        {
    	}
        public void destroyApp(boolean unconditional) 
        {
    		destroyApp(false);
    	}
    	public void commandAction(Command c, Displayable d)
    	{
    		if (c == select)
    		{
    			status.deleteAll();
    			status.append("Loading: ", null);
    			disp.setCurrent(status);
    			runAction = 0;
    			Thread cont = new Thread(this);
    			cont.start();
    		}
    		if (c == back)
    		{
    			interrupted = true;
    			try
    			{
    				if(player != null)
    				{
    					player.stop();
    					player.close();
    					player = null;
    				}
    				if(con != null)
    				{
    					con.close();
    					con = null;
    				}
    				if(is != null)
    				{
    					is.close();
    					is = null;
    				}
    				if(is1 != null)
    				{
    					is1.close();
    					is1 = null;
    				}
    				if(filecon != null)
    				{
    					filecon.close();
    					filecon = null;
    				}
    				if(os != null)
    				{
    					os.close();
    					os = null;
    				}
    			}
    			catch (Exception e)
    			{
    				status.append("Exception", null);
    				writeLog("BACK"+e);
    			}
    			disp.setCurrent(songs);
    		}
    		if(c == exit)
    		{
    			notifyDestroyed();
    		}
    	}
    	public void playerUpdate(Player player1, String event, Object eventData) 
    	{
    		this.event = event;
    		status.append("in player update", null);
    		if(event == PlayerListener.END_OF_MEDIA)
    		{
    			status.append("in end of media", null);
    			try
    			{
    				if(is1 != null)
    				{
    					is1.close();
    					is1 = null;
    				}
    				if(player != null)
    				{
    					player.stop();
    					player.close();
    					player = null;
    				}
    			}
    			catch (Exception e)
    			{
    				System.out.println("Exception in player update :"+e);
    				writeLog("PU"+e);
    				status.append("PU: "+e+":", null);
    			}
    			//createPlayer();
    		}
    	}
    	public void createPlayer()
    	{
    		try
    		{
    			String ctype = "";
    			chunkCount++;
    			status.append("i am in create Player", null);
    			is1 = filecon.openInputStream();
    			if(songs.getSelectedIndex() == 0)
    				ctype = "audio/mp3";
    			else if(songs.getSelectedIndex() == 1)
    				ctype = "audio/mp4";
    			else if(songs.getSelectedIndex() == 2)
    				ctype = "audio/3gpp";
    			player = Manager.createPlayer(is1, ctype);
    			player.realize();
    			player.prefetch();
    			player.setMediaTime(startTime);
    			player.addPlayerListener(this);
    			player.start();
    			status.append("playing: "+chunkCount, null);
    			runAction = 1;
    			t = new Thread(this);
    			t.start();
    		}
    		catch (Exception e)
    		{
    			System.out.println("Exception in create player is: "+e);
    			writeLog("CP"+e);
    			status.append("CP: "+e+":", null);
    		}
    
    	}
    	public void getSong()
    	{
    		action = 0;
    		Once = false;
    		chunkCount = 0;
    		try
    			{
    				if(songs.getSelectedIndex() == 0)
    					filecon = (FileConnection)Connector.open("file:///C:/Data/Sounds/Dhunster/hi.mp3");
    				else if(songs.getSelectedIndex() == 1)
    					filecon = (FileConnection)Connector.open("file:///C:/Data/Sounds/Dhunster/hi.mp4");
    				else if(songs.getSelectedIndex() == 2)
    					filecon = (FileConnection)Connector.open("file:///C:/Data/Sounds/Dhunster/hi.3gp");
    				if(filecon.exists())
    					filecon.delete();
    				filecon.create();
    				os = filecon.openOutputStream();
    				con = (HttpConnection) Connector.open("http://59.93.56.170/"+songs.getString(songs.getSelectedIndex()));
    				is = con.openInputStream();
    				totalsize = (int)con.getLength();
    				int size = totalsize/8;
    				chunk = new byte[size];
    				while((j != totalsize))
    				{
    					chunk = new byte[size];
    					length = 0;
    					while(length != chunk.length)
    					{
    						i = is.read(chunk, length, chunk.length - length);
    						if (i == -1) 
    						{
    							end = true;
    							break;
    						}
    						length += i;
    					}
    					if(!end)
    					{
    						action = action + 12;
    						status.append("Downloaded: "+action+"%", null);
    						os.write(chunk);
    						if(!Once)
    						{
    							Once = true;
    							createPlayer();
    						}
    					}
    					else
    						break;
    					j++;
    				}
    
    			}
    			catch(Exception e)
    			{	
    				System.out.println("Exception in start app: "+e);
    				writeLog("GS"+e);
    				status.append("GS: "+e+":", null);
    			}
    	}
    	public void run()
    	{
    		if(runAction == 0)
    		{
    			getSong();
    		}
    		else if (runAction == 1)
    		{
    			while(!interrupted)
    			{
    				try
    				{
    					if(player != null)
    					{
    						if(player.getMediaTime() > 0)
    							startTime = player.getMediaTime();
    						t.sleep(1000);
    						if(player.getMediaTime() == (player.getDuration()/8))
    						{
    							if(player != null)
    							{
    								player.stop();
    								player.close();
    								player = null;
    							}
    							if(is1 != null)
    							{
    								is1.close();
    								is1 = null;
    							}
    							status.append("in runAction1", null);
    							createPlayer();
    						}
    					}
    				}
    				catch (Exception e)
    				{
    					System.out.println("Exception in run :"+e);
    					writeLog("run"+e);
    					status.append("run: "+e+":", null);
    				}
    			}
    		}
    	}
    	public void writeLog(String s)
    	{
    		try
    		{
    			InputStream loginStream = log.openInputStream(); 
    			int i;
    			String data="";
    			while((i=loginStream.read())!=-1)
    			{
    				data = data+(char)i;
    			}
    			data = data+" : " +s;
    			loginStream.close();
    			OutputStream logStream = log.openOutputStream();
    			logStream.write(data.getBytes());
    			logStream.close();	
    		}
    		catch (Exception e)
    		{
    			//cc.logger.log("Exception in logger: "+e);
    			System.out.println("Exception in logger: "+e);
    			status.append("WL: "+e+":", null);
    		}
    	}
    	public void createFolder()
    	{
    		try
    		{
    			FileConnection f = (FileConnection)Connector.open("file:///C:/Data/Sounds/Dhunster");
    			if(!f.exists())
    				f.mkdir();
    			log = (FileConnection)Connector.open("file:///C:/Data/Sounds/Dhunster/log.txt");
    			if(log.exists())
    				log.delete();
    			log.create();
    		}
    		catch (Exception e)
    		{
    			System.out.println("Exception in createFolder: "+e);
    			status.append("CF"+e+":", null);
    			writeLog("CF"+e);
    		}
    	}
    }

  6. #6
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Please its veru urgent on nokia 3250

    Hi siva,
    As you told earlier you are downloading the file into the filesystem.Now you have to set a fileconnection for playing the sound before setting the inputStream.I suppose you havent done that..Please clarify
    Thanks
    Soku

  7. #7
    Registered User
    Join Date
    Apr 2006
    Posts
    32

    Exclamation Re: Please its very urgent on nokia 3250

    Hi Soku,

    As u said we r already creating a file connection in getsong and opening a input stream everytime in create player.
    please, send me some solution if find one.

    with rgs
    Siva

  8. #8
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Please its veru urgent on nokia 3250

    Hi siva,
    close the inputstream is1 and the fileconnection filecon in the Finally block of the createPlayer method.
    thanks
    Soku

  9. #9
    Registered User
    Join Date
    Mar 2008
    Posts
    46

    Re: Please its veru urgent on nokia 3250

    Hai
    Any One Can Suggest A Proper command line Mp4 Splitter.

    Vijay

Similar Threads

  1. ###Upgrading Firmware###
    By zahid44 in forum General Development Questions
    Replies: 27
    Last Post: 2008-10-21, 07:17
  2. Replies: 2
    Last Post: 2007-11-10, 13:19
  3. Urgent, about streaming of Nokia 6600
    By diabol in forum Streaming and Video
    Replies: 0
    Last Post: 2004-02-05, 10:57
  4. Please Help me on Nokia 7650 HttpConnection - URGENT
    By patelvk in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2003-05-07, 07:46
  5. nokia 7210 modem via IR doesn't work !
    By oussamaaiadi in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-03-06, 10:46

Posting Permissions

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