×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    10

    Downloading and saving Video to mobile from server.

    Hi,

    I am new in J2ME.
    I want to download video file from the server and save it in mobile device.
    Please tell me how to do? If possible give me the code.

    Thanks

  2. #2
    Registered User
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868

    Re: Downloading and saving Video to mobile from server.

    Hi maruffaiz,
    You have to open the connection to server where to the resource file available in the server . Get the input stream of the connection you have opened. And see it's content type if it is a video file then save that file in the mobile using the jsr75.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    10

    Re: Downloading and saving Video to mobile from server.

    Dear bhanuchandar.k,

    I tried, but not working.
    How to convert input stream into video file?
    Can you provide me the code.

    Thanks

  4. #4
    Nokia Developer Champion
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Downloading and saving Video to mobile from server.

    Hi,
    Please follow the following steps;

    1. open httpconnection.
    2. make sure that connections (HTTPconnection and FileConnection) in thread.
    3. open inputstream with httpconnection.
    4. open fileconnection.
    5. open outputstream with fileconnection.
    6. read data from inputstream byte by byte in a loop and write that byte to outputstream.
    7. when all the data wrote to outputstream then close all the connections and streams.

    follow these steps. Hope ur problem will get solved.

    thanks,
    jitu_goldie..
    thanks,
    jitu_goldie..

    KEEP TRYING..

  5. #5
    Registered User
    Join Date
    Sep 2007
    Location
    Mumbai, India
    Posts
    54

    Re: Downloading and saving Video to mobile from server.

    To be frank enough, its best to do a platform request here, since most of the S40 phones will give an out of memory exception.

  6. #6
    Nokia Developer Champion
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Downloading and saving Video to mobile from server.

    Hi,
    im not agree with u as this not a proper way to download any video or any other file from server.What in the case if at server there is no any option found for downloading that video or any other file.

    Quote Originally Posted by sanket2612 View Post
    To be frank enough, its best to do a platform request here, since most of the S40 phones will give an out of memory exception.
    thanks,
    jitu_goldie..
    thanks,
    jitu_goldie..

    KEEP TRYING..

  7. #7
    Registered User
    Join Date
    Jan 2009
    Posts
    10

    Re: Downloading and saving Video to mobile from server.

    Dear jitu_goldie,

    Can you please send me the code.

    Thanks

  8. #8
    Nokia Developer Champion
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Downloading and saving Video to mobile from server.

    Hi,

    please try the code written below..




    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;

    public class testMidlet extends MIDlet implements Runnable
    {
    Thread thread = null;
    public testMidlet()
    {
    thread = new Thread(this);
    thread.start();
    }

    public void startApp() {
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void run()
    {
    startDownloadAndWriting();
    }

    void startDownloadAndWriting()
    {
    try {
    HttpConnection httpConnection = null;
    FileConnection fileConnection = null;
    OutputStream outputStream = null;
    InputStream inputStream = null;
    String url_HTTP = ""; /////////initialize the url here......
    String url_FILE = ""; /////////initialize the url here......

    httpConnection = (HttpConnection) Connector.open(url_HTTP,Connector.READ);
    inputStream = httpConnection.openInputStream();

    fileConnection = (FileConnection)Connector.open(url_FILE,Connector.WRITE);
    if(fileConnection.exists())
    fileConnection.delete();
    fileConnection.create();
    outputStream = fileConnection.openOutputStream();
    int read;
    while((read = inputStream.read())!=-1)
    {
    outputStream.write(read);
    }
    } catch (IOException ex) {
    ex.printStackTrace();
    }
    finally
    {
    //////////close all the connections and streams.................

    }
    }

    }

    try and manage according to ur need..

    thanks,
    jitu_goldie..
    thanks,
    jitu_goldie..

    KEEP TRYING..

  9. #9
    Registered User
    Join Date
    Jan 2009
    Posts
    10

    Re: Downloading and saving Video to mobile from server.

    Dear jitu_goldie,

    Thank you very much for the code and your cooperation.

    Thanks

Similar Threads

  1. Problem in downloading 3gp video from server
    By santanu_dgn in forum Browsing and Mark-ups
    Replies: 9
    Last Post: 2007-06-22, 12:36
  2. Downloading And Saving Attachment Dialog Form Code Needed
    By mubx2000 in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-10-18, 12:44

Posting Permissions

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