📄 avtransportservice.java
字号:
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID"),
new UPnPActionArgument(
"Track",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"CurrentTrack"),
new UPnPActionArgument(
"TrackDuration",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"CurrentTrackDuration"),
new UPnPActionArgument(
"TrackMetaData",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"CurrentTrackMetaData"),
new UPnPActionArgument(
"TrackURI",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"CurrentTrackURI"),
new UPnPActionArgument(
"RelTime",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"RelativeTimePosition"),
new UPnPActionArgument(
"AbsTime",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"AbsoluteTimePosition"),
new UPnPActionArgument(
"RelCount",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"RelativeCounterPosition"),
new UPnPActionArgument(
"AbsCount",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"AbsoluteCounterPosition")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
args[1].setValue(new Integer(currentTrack));
args[2].setValue("02:10");
args[3].setValue(avTransportUriMetaData);
args[4].setValue(avTransportUri);
args[5].setValue("");
args[6].setValue("");
args[7].setValue(new Integer(0));
args[8].setValue(new Integer(1));
}
}
private class GetDeviceCapabilitiesAction extends UPnPAction {
public GetDeviceCapabilitiesAction () {
super(
"GetDeviceCapabilities",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID"),
new UPnPActionArgument(
"PlayMedia",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"PossiblePlaybackStorageMedia"),
new UPnPActionArgument(
"RecMedia",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"PossibleRecordStorageMedia"),
new UPnPActionArgument(
"RecQualityModes",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"PossibleRecordQualityModes")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
args[1].setValue(possiblePlaybackStorageMedia);
args[2].setValue(possibleRecordStorageMedia);
args[3].setValue(possibleRecordQualityModes);
}
}
private class GetTransportSettingsAction extends UPnPAction {
public GetTransportSettingsAction () {
super(
"GetTransportSettings",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID"),
new UPnPActionArgument(
"PlayMode",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"CurrentPlayMode"),
new UPnPActionArgument(
"RecQualityMode",
UPnPActionArgument.ARGUMENT_DIRECTION_OUT,
"CurrentRecordQualityMode")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
args[1].setValue(CurrentPlayMode_in);
args[1].setValue(CurrentRecordQualityMode_in);
}
}
private class StopAction extends UPnPAction {
public StopAction () {
super(
"Stop",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
synchronized(pi) {
Player p = pi.getPlayer();
try {
p.stop();
} catch (MediaException e) {
LOG.fatal(e);
e.printStackTrace();
}
}
}
}
private class PlayAction extends UPnPAction {
public PlayAction () {
super(
"Play",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID"),
new UPnPActionArgument(
"Speed",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"TransportPlaySpeed")});
}
public void invoke(UPnPActionArgument[] args){
LOG.debug("PlayAction");
try {
int instanceID = Integer.parseInt((String)args[0].getValue());
//
// Check that InstanceID = 0, since that is the only
// instance ID allowed.
//
if (instanceID != 0) {
LOG.warn(
"Illegal InstanceID(" + (String)args[0].getValue() +
")");
// throw illegal UPnP argument exception here
}
if (playerRealization != null) {
if (playerRealization.isAlive()) {
try {
LOG.debug(
"Must wait for playerRealization to finish first...");
playerRealization.join();
//pi.wait();
} catch (InterruptedException ie) {
LOG.debug("InterruptedException while waiting for playerRealization");
LOG.debug(ie);
} finally {
LOG.debug("Finished! playerRealization just finished!");
}
}
Player p = pi.getPlayer();
if (p == null) {
LOG.warn("Illegal state of player, player is null");
// throw some UPnP exception saying that player is in wrong state.
return;
}
int playerState = p.getState();
if (playerState != Player.PREFETCHED) {
LOG.warn("Illegal state of player(" + playerState + ")");
// throw some UPnP exception saying that player is in wrong state.
}
//
// TODO Check that TransportPlaySpeed argument is legal.
//
//Object o2 = args[1].getValue();
//TransportPlaySpeed_in = (String) o2;
System.out.println("Start to play media...");
p.start();
System.out.println("Hopefully music is playing now!");
}
} catch (MediaException e) {
LOG.debug("MediaException while starting to play");
LOG.debug(e);
e.printStackTrace();
} catch (Exception e) {
LOG.debug("Exception while starting to play");
LOG.debug(e);
e.printStackTrace();
}
}
}
private class SeekAction extends UPnPAction {
public SeekAction () {
super(
"Seek",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID"),
new UPnPActionArgument(
"Unit",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_SeekMode"),
new UPnPActionArgument(
"Target",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_SeekTarget")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
/*
Object o2 = args[1].getValue();
A_ARG_TYPE_SeekMode_in = (String) o2;
Object o3 = args[2].getValue();
A_ARG_TYPE_SeekTarget_in = (String) o3;
*/
}
}
private class NextAction extends UPnPAction {
public NextAction () {
super(
"Next",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
}
}
private class PreviousAction extends UPnPAction {
public PreviousAction () {
super(
"Next",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
}
}
private class PauseAction extends UPnPAction {
public PauseAction (){
super(
"Next",
new UPnPActionArgument[]{
new UPnPActionArgument(
"InstanceID",
UPnPActionArgument.ARGUMENT_DIRECTION_IN,
"A_ARG_TYPE_InstanceID")});
}
public void invoke(UPnPActionArgument[] args){
int instanceID = Integer.parseInt((String)args[0].getValue());
}
}
private final class SimplePlayerListener implements PlayerListener {
public void playerUpdate(Player player, String event, Object eventData) {
LOG.debug("Player update: " + event);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -