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

VLC for Android and Chrome OS specific usage questions
dfdf
Blank Cone
Blank Cone
Posts: 39
Joined: 22 Dec 2013 23:54

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

Postby dfdf » 23 Dec 2013 00:15

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!

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

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

Postby edwardw » 23 Dec 2013 19:45

Subscribe to the events and fire the necessary events.

dfdf
Blank Cone
Blank Cone
Posts: 39
Joined: 22 Dec 2013 23:54

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

Postby dfdf » 24 Dec 2013 03:15

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!
Last edited by dfdf on 24 Dec 2013 14:52, edited 1 time in total.

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

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

Postby edwardw » 24 Dec 2013 04:11

By events, for example, such as MediaPlayerPositionChanged...

dfdf
Blank Cone
Blank Cone
Posts: 39
Joined: 22 Dec 2013 23:54

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

Postby dfdf » 24 Dec 2013 05:28

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!

dfdf
Blank Cone
Blank Cone
Posts: 39
Joined: 22 Dec 2013 23:54

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

Postby dfdf » 24 Dec 2013 14:50

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... }

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

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

Postby edwardw » 24 Dec 2013 15:25

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.

dfdf
Blank Cone
Blank Cone
Posts: 39
Joined: 22 Dec 2013 23:54

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

Postby dfdf » 24 Dec 2013 16:12

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!


Return to “VLC for Android and Chrome OS”

Who is online

Users browsing this forum: No registered users and 60 guests