×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    69

    Unable to play video

    Hi all,

    I'm trying to run the following code, however its gives me nothing. Other than the video, everything's running fine. Please check through the code if you find anything going wrong.


    else if (c == Demo)
    {

    form1.deleteAll();
    form1.setTitle("Demo Video");
    form1.removeCommand(Next1);
    form1.removeCommand(Exit);


    playFromResource();



    }


    public void playFromResource()

    {

    try

    {

    InputStream in = getClass().getResourceAsStream("/Video/Hitesh.mpeg");
    if (in != null)
    {
    mPlayer = Manager.createPlayer(in, "video/mpeg");
    }else
    {
    alert = new Alert("Alert", "No video", null, null);
    display.setCurrent(alert);
    return;

    }
    mPlayer.prefetch();

    mPlayer.realize();
    if((mVidc = (VideoControl)mPlayer.getControl("VideoControl"))!=null)

    {

    mVideoItem = (Item)mVidc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);
    form1.append(mVideoItem);
    }

    mPlayer.prefetch();
    mPlayer.start();
    // form1.removeCommand(mPlayCommand);
    display.setCurrent(form1);


    }
    catch (Exception e)

    {e.printStackTrace();}

    }

    waiting for response.

  2. #2
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Unable to play video

    Are you getting any exception if yes then please let us know so that we can slove your problem
    Anshu Chauhan
    J2me Developer

  3. #3
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    69

    Re: Unable to play video

    Yes, when i tried running it with .3gp it gave me a media error but when i play with mpeg, it gives me that alert for input stream to be null.

    i checked the location of the file and matched it correctly on the code also checked the .jar file....the file structure is same there too......

  4. #4
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Unable to play video

    change Manager.createPlayer(in, "video/mpeg"); with
    Manager.createPlayer(is, "video/3gpp");

    becoz you are using 3gp file. I m sure it will work

    and for mpeg file i think your mobile will not support that
    Anshu Chauhan
    J2me Developer

  5. #5
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    69

    Re: Unable to play video

    it gives me an error below



    javax.microedition.media.MediaException: Cannot create a Player for: video/3gpp
    at javax.microedition.media.Manager.getPlayerFromType(Manager.java:818)
    at javax.microedition.media.Manager.createPlayer(Manager.java:868)
    at javax.microedition.media.Manager.createPlayer(Manager.java:745)
    at AirtelMainMidlet.playFromResource(AirtelMainMidlet.java:109)
    at AirtelMainMidlet.commandAction(AirtelMainMidlet.java:310)

  6. #6
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Unable to play video

    ON which handset you are trying to run your application can you please mention that. or you playing video file on emulator
    Anshu Chauhan
    J2me Developer

  7. #7
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    69

    Re: Unable to play video

    well i believe there is somethings wrong with the code.............cause i have tried running this code on most of the phones...............

    the error was on emulator.

    phones i have tried on - Nokia N70, Sony Erricson K750i, I-mate(which hangs god knows why) and HTC(don't know the model)

  8. #8
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    69

    Re: Unable to play video

    I'm giving out the whole code i have......................to it more comprehensive




    Code:
    import java.io.InputStream;
    import javax.microedition.media.Player;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.Manager;
    import javax.microedition.media.control.VideoControl;
    /**
     * @author hitesh
     */
    public class AirtelMainMidlet extends MIDlet implements CommandListener {
    
    
        private Display display;
    
        private Form form1;
        public Image image;
    
        public List list;
    
        private TextBox TextBox, bTextBox, cTextBox, dTextBox, eTextBox, fTextBox, gTextBox;
    
    
    
    
        // The Commands used in the code.
    
        private Command Next = new Command("Next", Command.OK, 1);
        private Command Exit = new Command("Exit", Command.EXIT, 1);
        private Command Next1 = new Command("Move on", Command.OK, 1 );
        private Command Next2 = new Command("Next", Command.OK, 1 );
        private Command Back1 = new Command("Back", Command.BACK ,1);
        private Command Demo  = new Command("Demo", Command.OK, 1);
    
    
        private Alert alert;
        private Player mPlayer;
        private VideoControl mVidc;
        private Item mVideoItem;
    
    
        // Midlet's constuctor
    
        public AirtelMainMidlet()
        {
    
             display = Display.getDisplay(this);
    
    
             form1 = new Form ("Airtel Missed Call Alerts");// setting form 1
    
             form1.addCommand(Next);
             form1.addCommand(Exit);         
             form1.setCommandListener(this);
    
             addData();
    
            // throw new UnsupportedOperationException("Not yet implemented");
        }
    
    
    
        
    
        boolean addData()
        {
    
        display = Display.getDisplay(this);
    
        list = new List("   Frequently Asked Questions", List.IMPLICIT);// this is the first line where it shows an error
    
            /*list.append("Question1", null);
            list.append("Question2", null);
            list.append("Question3", null);*/
    
           list.append("1.	Do you have any service to ensure that I don’t miss any important calls?", null);
           list.append("2.	How do I activate Missed Call Alerts?", null);
           list.append("3.	Can you activate Missed Call Alerts for me?", null);
           list.append("4.	What is the monthly rental for Missed Call Alerts?", null);
           list.append("5.	Will I be able to get missed call alerts for the previous month?", null);
           list.append("6.	Are Missed Called Alerts free?", null);
           list.append("7.	Could you please tell me the renewal date for Missed Call Alerts?", null);
    
    
           list.addCommand(Next2);
           list.addCommand(Exit);
           list.setCommandListener(this);
           return(true);
    
    
        } 
    
    
         public void playFromResource()
    
        {
    
        try
    
        {
    
        InputStream in = getClass().getResourceAsStream("/Video/Airtel.3gp");
        if (in != null)
        {
        mPlayer = Manager.createPlayer(in, "video/3gpp");
        }else
        {
            alert = new Alert("Alert", "No video", null, null);
            display.setCurrent(alert);
            return;
    
        }
        mPlayer.prefetch();
    
        mPlayer.realize();
        if((mVidc = (VideoControl)mPlayer.getControl("VideoControl"))!=null)
    
        {
    
        mVideoItem = (Item)mVidc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);
        form1.append(mVideoItem);
        }
    
        mPlayer.prefetch();
        mPlayer.start();
       // form1.removeCommand(mPlayCommand);
        display.setCurrent(form1);
    
    
        }
        catch (Exception e)
    
        {e.printStackTrace();}
    
         }
    
    
    
    
        public void startApp() {
            
             
             display.setCurrent(form1);// Calling form1
    
    
        }
    
        public void pauseApp() {
        }
    
        public void destroyApp(boolean unconditional) {
        }
    
        public void commandAction(Command c, Displayable d) {
    
            if (c == Exit)
            {
    
                this.notifyDestroyed(); // Ends the application
    
            }
    
            else if(c == Next) // Clears the contents from the form1 and adds image to it
            {
    
                form1.deleteAll();
                form1.setTitle("Control Keys");
                form1.removeCommand(Next);
                form1.removeCommand(Exit);
    
                try{
                image = Image.createImage("/Image/Airtel.png");
                }catch(Exception e){}
    
                form1.append(image);
                form1.addCommand(Exit);
                form1.addCommand(Next1);
                form1.setCommandListener(this);
    
            }
    
    
            else if(c == Next1)
            {
    
                display = Display.getDisplay(this);
                display.setCurrent(list);
    
             }
    
            else if (c == Next2 || c == List.SELECT_COMMAND)
            {
    
                int x = list.getSelectedIndex();
               /* String selection = list.getString(x);
                alert = new Alert("Option Selected", selection, null, null);
                alert.setTimeout(Alert.FOREVER);
                alert.setType(AlertType.INFO);
                display.setCurrent(alert);*/
    
                switch(x) {
    
                    case 0:
    
                             String  string1 = "Explain to the customer that Airtel offers a service called Missed Call Alerts, which helps them to later retrieve their missed call details whenever their phone was switched off or not reachable.";
                            TextBox aTextBox = new TextBox("", string1, 2048, TextField.UNEDITABLE);
                            aTextBox.addCommand(Back1);
    
                            aTextBox.setCommandListener(this);
                            display.setCurrent(aTextBox);
                            break;
    
                    case 1:
    
                            final String string2 = "Ask the customer to send MCA ACTV to 222 or activate the service from your end if the customer is finding it difficult to do so.Click the Demo button to view the demo.";
                            bTextBox = new TextBox("", string2, 2048, TextField.UNEDITABLE);
    
                            bTextBox.addCommand(Back1);
                            bTextBox.addCommand(Demo);
    
                            bTextBox.setCommandListener(this);
                            display.setCurrent(bTextBox);
                            break;
    
                    case 2:
    
                            final String string3 = "Activate Missed Call Alerts for the customer using the MCA URL.";
                            cTextBox = new TextBox("", string3, 2048, TextField.UNEDITABLE);
    
                            cTextBox.addCommand(Back1);
    
                            cTextBox.setCommandListener(this);
                            display.setCurrent(cTextBox);
                            break;
    
                     case 3:
    
                            final String string4 = "Inform the customer that the rental for Missed Call Alerts is Rs 15 per month and this amount will be deducted from their account as soon as the service is activated";
                            dTextBox = new TextBox("", string4 , 2048, TextField.UNEDITABLE);
    
                            dTextBox.addCommand(Back1);
    
                            dTextBox.setCommandListener(this);
                            display.setCurrent(dTextBox);
                            break;
    
                      case 4:
    
                            final String string5 = "Tell the customer that they will only get missed call alerts for the last 4 hours and will not be able to get alerts for the previous month.";
                            eTextBox = new TextBox("", string5, 2048, TextField.UNEDITABLE);
    
                            eTextBox.addCommand(Back1);
    
                            eTextBox.setCommandListener(this);
                            display.setCurrent(eTextBox);
                            break;
    
                      case 5:
    
                            final String string6= "Explain that Missed Call Alerts is not free and educate the customer about the monthly rental for the service.";
                            fTextBox = new TextBox("", string6, 2048, TextField.UNEDITABLE);
    
                            fTextBox.addCommand(Back1);
    
                            fTextBox.setCommandListener(this);
                            display.setCurrent(fTextBox);
                            break;
    
    
                      case 6:
    
                            final String string7 = "You can find this information under Adjustments in Minsat or OTHR CDR in Pacs. Note down the date and inform the customer.";
                            gTextBox = new TextBox("", string7, 2048, TextField.UNEDITABLE);
    
                            gTextBox.addCommand(Back1);
    
                            gTextBox.setCommandListener(this);
                            display.setCurrent(gTextBox);
                            break;
    
            
            }
    
    
            
    //        throw new UnsupportedOperationException("Not supported yet.");
        }
    
    
            else if (c == Back1)
                {
    
                    display.setCurrent(list);
    
                }
    
            else if (c == Demo)
            {
    
                form1.deleteAll();
                form1.setTitle("Demo Video");
                form1.removeCommand(Next1);
                form1.removeCommand(Exit);
    
    
                playFromResource();
                
    
    
            }
    
    
    
        }
    }

  9. #9
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Unable to play video

    Quote Originally Posted by hiteshrawat View Post
    the error was on emulator.


    Dont try to play 3gp file on emulator Most of the time emulator does not support 3gp
    Anshu Chauhan
    J2me Developer

  10. #10
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    69

    Re: Unable to play video

    I tried running this on Nokia N 70............it gave me the alert which i coded to be shown when the input stream is null.............any guesses why it shows the input stream to be null???

  11. #11
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Unable to play video

    May be you were playing mpeg file .
    Hey go through this link and let me know whether this help you or not

    http://www.forum.nokia.com/infocente...E77D32F2B.html
    Anshu Chauhan
    J2me Developer

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

    Thumbs up Re: Unable to play video

    Quote Originally Posted by hiteshrawat View Post
    I tried running this on Nokia N 70............it gave me the alert which i coded to be shown when the input stream is null.............any guesses why it shows the input stream to be null???
    Hi Hitesh,
    Whats the error u get while playing the 3gp file. Have u handle the exception. I would like to suggest u that print those errors on some form or alert.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  13. #13
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    69

    Re: Unable to play video

    well what i did is that......i kept a try catch block

    Code:
     InputStream in = getClass().getResourceAsStream("/Muzik/Airtel.3gp");
        if (in != null)
        {
        mPlayer = Manager.createPlayer(in, "video/3gpp");
        }else
        {
            alert = new Alert("Alert", "No video", null, null);
            display.setCurrent(alert);
            return;
    
        }
    i'm showing a alert if the input stream is null...........and same is the message i'm getting again an again when i run it on the phone.

  14. #14
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Unable to play video

    Hi,
    if input stream is null then there is some issue while you are reading the file.please check that you have successfully read the file,like you should check that name,extension,type.

    And follow the jitu's suggestion,print the stack trace of the exceptions that you might be getting.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  15. #15
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Unable to play video

    Quote Originally Posted by hiteshrawat View Post
    well what i did is that......i kept a try catch block

    Code:
     InputStream in = getClass().getResourceAsStream("/Muzik/Airtel.3gp");
        if (in != null)
        {
        mPlayer = Manager.createPlayer(in, "video/3gpp");
        }else
        {
            alert = new Alert("Alert", "No video", null, null);
            display.setCurrent(alert);
            return;
    
        }
    i'm showing a alert if the input stream is null...........and same is the message i'm getting again an again when i run it on the phone.
    HI,
    please check that the file is on the correct path,like in the res folder,then Muzik and there must be Airtel.3gp file.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. cant play large video
    By zhouliwx in forum Mobile Java General
    Replies: 3
    Last Post: 2010-07-12, 11:28
  2. Play video with a active call in progress
    By mawe in forum Symbian Media (Closed)
    Replies: 14
    Last Post: 2008-11-20, 14:23
  3. Unable To Play a Video File In symbian 9.1 device
    By mailkamlesh in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-08-14, 18:06
  4. Unable To Play a Video File In symbian 9.1 device
    By mailkamlesh in forum Symbian
    Replies: 0
    Last Post: 2006-08-14, 08:15
  5. Play video on Canvas with N 6600 doesnt work. Please help!!!
    By Robert111 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-02-22, 08:45

Posting Permissions

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