Page 1 of 1

Feature req:.play(starttime,endtime) or .play(dur)

Posted: 23 Dec 2013 00:15
by dfdf
Hi Sirs!
We need to play some periods of the whole media,this means we need some kind of feature like this:

mLibVLC.play(starttime,endtime);
or:
mLibVLC.play(duration) for play a duration time from current postion then pause.BTW,it will be the best if these can be done in "synchronous" mode,this way we need not to add waiting logic by ourself.

For doing this,we need a open-only feature,but now,LibVLC can only open a media and play automaticly immediately useing readMedia(url),I have to stop or pause it immediately,BUT,unfortunately most of the operatings are not raliable,I mean libVLC.stop(),libVLC.pause(),even including libVLC.setVolume(),libVLC.setRate() very often can not work in the working thread( distinguishing the UI thread),I have to use the ugly looping code to check if they take effects,taking the risk of making ANR faults.

For example,some code like this:

mLibVLC.readMedia(mLocation,disvd);
while(mLibVLC.isPlaying()){
act.runOnUiThread(new Runnable() {
public void run() {
mLibVLC.stop();
}
});
}
Some time,mLibVLC.isPlaying() return false immediately after readMedia(),but it centainly actunally will play soon, no good way to control the condition.

Thank you very much!

Re: Feature req:.play(starttime,endtime) or .play(dur)

Posted: 23 Dec 2013 19:45
by edwardw
Subscribe to the events and fire the necessary events.

Re: Feature req:.play(starttime,endtime) or .play(dur)

Posted: 24 Dec 2013 03:15
by dfdf
Subscribe to the events and fire the necessary events.
Thanks for your reply,Sir.

I don't understand what exactly do you mean when you talk about "events". You are meaning VideoPlayerEventHandler?I study it for a minute but don't understand how to use it for our purpose.

particularly,if we want to play a video one by one sentence according to the time information reading from the subtitle file, how we can do by events mechanism you have mentioned? My pseudo code likes this:

Code: Select all

mLIbVLC.openMedia(mLocation); for(Subtitle asubtitle:subtitles){ int starttime=asubtitle.starttime; int endtime=asubtitle.endtime; mLibVLC.play(starttime,endtime); //media pause here,wait to do some other thing... }
Thank you very much!

Re: Feature req:.play(starttime,endtime) or .play(dur)

Posted: 24 Dec 2013 04:11
by edwardw
By events, for example, such as MediaPlayerPositionChanged...

Re: Feature req:.play(starttime,endtime) or .play(dur)

Posted: 24 Dec 2013 05:28
by dfdf
By events, for example, such as MediaPlayerPositionChanged...
Understand,I will try that way.
But we're using LibVLC in a working thread,maybe events mechanism is not necessary,instead,it means a complicated logic and some ugly codes. If there are some synchronous methods,the code maybe rather simple and graceful.

Meanwhile,the problems around LibVLC.setVolume() and libVLC.setRate() are not involved with events.

Thank you very much!

Re: Feature req:.play(starttime,endtime) or .play(dur)

Posted: 24 Dec 2013 14:50
by dfdf
By events, for example, such as MediaPlayerPositionChanged...
Dear Edwardw,I have tried you suggestion,but not work for me,the code looks like this:

Code: Select all

case EventHandler.MediaPlayerPositionChanged: if(!c.allowplay()){ try { LibVLC.getInstance().pause(); } catch (LibVlcException e) { } } break;
In fact,every time I need pause play,it will do this two or three time untill it real stops play,and make a lot ANRs.Maybe complicated logic and mass codes can work around this,I am so fear of that,I love the neat logic and code like this:

Code: Select all

mLIbVLC.openMedia(mLocation); for(Subtitle asubtitle:subtitles){ int starttime=asubtitle.starttime; int endtime=asubtitle.endtime; mLibVLC.play(starttime,endtime); //media pause here,wait to do some other thing... }

Re: Feature req:.play(starttime,endtime) or .play(dur)

Posted: 24 Dec 2013 15:25
by edwardw
If such a method were implemented in VLC, it would have the same mechanism as described here.

Look at how position is monitored in the VLC for Android app; we use the same events mechanism. In fact normal desktop libVLC needs you to do the same thing.

Re: Feature req:.play(starttime,endtime) or .play(dur)

Posted: 24 Dec 2013 16:12
by dfdf
If such a method were implemented in VLC, it would have the same mechanism as described here.

Look at how position is monitored in the VLC for Android app; we use the same events mechanism. In fact normal desktop libVLC needs you to do the same thing.
OK,I've got your point,thank you again!