This discussion is archived
5 Replies Latest reply: Nov 20, 2010 3:19 AM by DarrylBurke RSS

RecordControl commit doesn't work second time

843849 Newbie
Currently Being Moderated
I'm writing a video app that needs to be paused. When paused we call commit and save the data locally.
                recordControl.commit();
Upon resuming we call
          recordControl.setRecordStream();
          recordControl.startRecord();
however when we call recordControl.commit() the SECOND TIME no more data can be retrieved. Meanwhile, We're not closing or stopping the Player at all. We even went as far as creating a new recordControl after every pause but no data could be retrieved after commit. It seems as if only one call to commit() is allowed per player per RecordControl... this seems bogus. Are calls to setRecordStream and startRecord enough for commit to work multiple times for a single realized player? If so, is this the correct way? Thanks
  • 1. Re: RecordControl commit doesn't work second time
    843849 Newbie
    Currently Being Moderated
    http://www.blackberry.com/developers/docs/4.1api/javax/microedition/media/control/RecordControl.html#commit()

    according to this, you should do setRecordStream or setRecordLocation befor calling a
    second time commit() !
  • 2. Re: RecordControl commit doesn't work second time
    843849 Newbie
    Currently Being Moderated
    Please do read the entire post first. I'm already doing that. That's what i meant by

    "...Upon resuming we call
              recordControl.setRecordStream();
              recordControl.startRecord();
    ..."


    So, in case this is not clear, the sequence goes like this

    1. initialize player, recordControl, videoControl and set the RecordStream
    player = Manager.createPlayer("capture://audio_video");
    player.realize();
    
    videoControl = (VideoControl)(player.getControl("VideoControl"));
    videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this.canvas);
    
                 
    recordControl = (RecordControl)player.getControl("RecordControl");
     recordControl.setRecordStream(this.buffer);
    2. start like this:
    videoControl.setVisible(true);
    recordControl.startRecord();
    player.start();
    3. user presses "pause" and EVERYTHING we do is;
    recordControl.commit();
    I've stried stopping the player also but it shouldn't be necessary, so I'm not stopping it. Notice that I'm not closing the player either.

    At this stage I get everything off my buffer (this.buffer) and I do get my data. I already rechecked it and I AM getting stuff. the problem starts from this point on

    4. A while later the user presses 'resume' and I call:
                    this.buffer = new ByteArrayOutputStream();
              recordControl.setRecordStream(this.buffer);
              recordControl.startRecord();
    ..."

    5. User presses 'pause' - same as in step #3 - and the same code is called
    recordControl.commit();
    yet, for some reason I'm nolonger able to get anything from this.buffer.

    I am following the instructions. I am calling setRecordStream BEFORE resuming. What's happening? Any folks have had similar trouble with this?
    I'm using a Sony Ericsson W710i btw.

    cheers,
  • 3. Re: RecordControl commit doesn't work second time
    843849 Newbie
    Currently Being Moderated
    have you tried with creating a new ByteArrayOutputStream?
  • 4. Re: RecordControl commit doesn't work second time
    814592 Newbie
    Currently Being Moderated
    I have the same problem. After first commit(), calling setRecordStream() throws IllegalStateException: "startRecord() has been called and commit has not been called". Scheme looks like this:
    Player p= Manager.createPlayer("capture://audio?encoding=pcm");
    p.realize();
    RecordControl rc= (RecordControl)p.getControl("RecordControl");
    ByteArrayOutputStream nbos= new ByteArrayOutputStream();
    rc.setRecordStream(nbos);
    p.start();
    rc.startRecord();
    
    Thread.sleep(6000);
    rc.stopRecord();
    
    rc.commit();
    nbos.flush();
     byte[] barr= nbos.toByteArray();   // up to here everything is ok and i get my recorded bytes
    
    Thread.sleep(5000);       // let's wait a moment before starting next recording
    rc.setRecordStream(nbos);    //this line throws IllegalStateException
                                            //I also tried rc.setRecordStream(new ByteArrayOutputStream()); but no effect
    ...
    It's obvious that commit() is called befere second setRecordStream() but exception states otherwise
    Has anyone handled this?

    Maybe author of this thread solved this?

    Any help appreciated :)
  • 5. Re: RecordControl commit doesn't work second time
    DarrylBurke Guru Moderator
    Currently Being Moderated
    Moderator advice: Please don't post in threads that are long dead and don't hijack another poster's thread. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
    Moderator action: Locking this thread.

    db