Skip to main content

Change title

4 replies [Last post]
francoislionet
Offline
Joined: 2008-01-13

Hello,

Me again. This is all me, not here for month, and then I ask many questions. Sorry for that.

I know how to change a playlist, go to a specific mark. But ban someone give the code to change the current title playing?

Thanks in advance, Francois

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jscons
Offline
Joined: 2009-02-01

Francois,

Try this bit of code:

import javax.tv.service.SIManager;
import javax.tv.service.selection.ServiceContextFactory;
import javax.tv.xlet.XletContext;

import org.bluray.net.BDLocator;
import org.bluray.ti.Title;
import org.bluray.ti.selection.TitleContext;

...

/**
* Jump to a new Title
* @param xtc the Xlet context
* @param t the target Title number
*/
public static void changeTitle(XletContext xtc, int t)
{
ServiceContextFactory factory = ServiceContextFactory.getInstance();

try
{
TitleContext tc = (TitleContext)factory.getServiceContext(xtc);
SIManager manager = SIManager.createInstance();
BDLocator loc = new BDLocator(null, t, -1);
Title title = (Title)manager.getService(loc);

if (title != null)
{
tc.start(title, true);
}
}
catch (Throwable e)
{
return;
}

}

That should do what you need.

Best,

- Jay

elbob
Offline
Joined: 2008-10-01

One more thing worth mentioning:

You need a permission file called "bluray.YourXletName.perm" and set
service selection to true.


francoislionet
Offline
Joined: 2008-01-13

Thank youy very much to you all!

Francois

bbk
Offline
Joined: 2006-10-13

Hello Francois,

this is how it could be done using TV spec only:

1. Step 1 =========================================

You first need to access your Xlet's primary ServiceContext instance:

...
ServiceContext yourPrimaryCtx =
javax.tv.service.selection.ServiceContextFactory.getServiceContext(xc),
...
where xc is initXlet() paramter value for your Xlet.

2. Step 2 =================================
Using that xc, you call then
2.1. yourPrimaryCtx.select(SIManager.createInstance().getService(serviceLocator))
where serviceLocator is the locator of your title,
it must include disc_id part(that implies it is transport-dependant in Bluray terms).

or
2.2 yourPrimaryCtx.select(Locator[] serviceComponentLocators)
where
serviceComponentLocators is 1+ element array of ServiceComponent-s
of the Title to be selected.
---
Consequences of actions in 2) shall be:
=============================
2.1. If your Xlet is not signaled in newly selected title,
it shall be destroyed.

2.2 if your xlet is signaled in currently
selected title's bdjo as TITLE_UNBOUND_DISC_BOUND or
TITLE_UNBOUND_DISC_UNBOUND
and is signaled in new title's bdjo (any type of signaling):
your Xlet shall not be destroyed. Xlet
becomes managed by newly selected
title's signaling. So, if it is signaled as TITLE_BOUND_DISC_BOUND
in new title, it shall become TITLE_BOUND_DISC_BOUND
after selection succeeds.

2.3. if your Xlet is signaled in currently
selected title's bdjo as TITLE_BOUND_DISC_BOUND
your Xlet shall terminate. And then:
If it is signaled in newly selected title's bdjo, it shall
start again and shall become managed by newly selected title signaling.

3. Step 3 ======================================

After selection succeeded, you then need wait for NormalContentEvent
as a signal that your title selection accomplished in your ServiceContextListener.
To do that, you have to get subscribed as primary ServiceContextListener:
just add your listener by calling.

yourPrimaryCtx.addListener(ServiceContextListener listener)

Note! call yourPrimaryCtx.ServiceaddListener() before Step 2! or your listener
shall miss the NormalContentEvent which gets generated asynchronously.

Then you've got a few of options:
- NormalContentEvent shall signal that successful selection occurs.
- SelectionFailedEvent will result in selection failure: see it's reason why
it has happened.
- You catch interrupted exception in your thread! It means that
title selection has accomplished and resulted in 2.1 or 2.3 behavior.
You then need to:
- modify waiting threads to wait for one of two events:
3.1 NormalContentEvent
or
3.2 your Xlet's destroyXlet is called by the platform itself.

In case 3.2, you need to successfully release resources etc.