org.fourthline.cling.support.model.Channel Java Examples

The following examples show how to use org.fourthline.cling.support.model.Channel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
synchronized public void setVolume(double volume) {
    Log.i(TAG,"setVolume " + volume);
    storedVolume = getVolume();
    
    Intent intent = new Intent();
    intent.setAction(Action.DMR);
    intent.putExtra("helpAction", Action.SET_VOLUME);
    intent.putExtra("volume", volume);

    mContext.sendBroadcast(intent);        
    
    ChannelMute switchedMute =
            (storedVolume == 0 && volume > 0) || (storedVolume > 0 && volume == 0)
                    ? new ChannelMute(Channel.Master, storedVolume > 0 && volume == 0)
                    : null;

    getRenderingControlLastChange().setEventedValue(
            getInstanceId(),
            new RenderingControlVariable.Volume(
                    new ChannelVolume(Channel.Master, (int) (volume * 100))
            ),
            switchedMute != null
                    ? new RenderingControlVariable.Mute(switchedMute)
                    : null
    );
}
 
Example #2
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
synchronized public void setVolume(double volume) {
    Log.i(TAG,"setVolume " + volume);
    storedVolume = getVolume();
    
    Intent intent = new Intent();
    intent.setAction(Action.DMR);
    intent.putExtra("helpAction", Action.SET_VOLUME);
    intent.putExtra("volume", volume);

    mContext.sendBroadcast(intent);        
    
    ChannelMute switchedMute =
            (storedVolume == 0 && volume > 0) || (storedVolume > 0 && volume == 0)
                    ? new ChannelMute(Channel.Master, storedVolume > 0 && volume == 0)
                    : null;

    getRenderingControlLastChange().setEventedValue(
            getInstanceId(),
            new RenderingControlVariable.Volume(
                    new ChannelVolume(Channel.Master, (int) (volume * 100))
            ),
            switchedMute != null
                    ? new RenderingControlVariable.Mute(switchedMute)
                    : null
    );
}
 
Example #3
Source File: EventedValueChannelVolumeDB.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected ChannelVolumeDB valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Integer volumeDB = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            volumeDB = (new UnsignedIntegerTwoBytesDatatype()
                    .valueOf(attribute.getValue()))
                    .getValue().intValue(); // Java is fun!
    }
    return channel != null && volumeDB != null ? new ChannelVolumeDB(channel, volumeDB) : null;
}
 
Example #4
Source File: EventedValueChannelVolume.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ChannelVolume valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Integer volume = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            volume = (new UnsignedIntegerTwoBytesDatatype()
                    .valueOf(attribute.getValue()))
                    .getValue().intValue(); // Java is fun!
    }
    return channel != null && volume != null ? new ChannelVolume(channel, volume) : null;
}
 
Example #5
Source File: EventedValueChannelLoudness.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ChannelLoudness valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Boolean loudness = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            loudness = new BooleanDatatype().valueOf(attribute.getValue());
    }
    return channel != null && loudness != null ? new ChannelLoudness(channel, loudness) : null;
}
 
Example #6
Source File: EventedValueChannelVolumeDB.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ChannelVolumeDB valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Integer volumeDB = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            volumeDB = (new UnsignedIntegerTwoBytesDatatype()
                    .valueOf(attribute.getValue()))
                    .getValue().intValue(); // Java is fun!
    }
    return channel != null && volumeDB != null ? new ChannelVolumeDB(channel, volumeDB) : null;
}
 
Example #7
Source File: EventedValueChannelLoudness.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected ChannelLoudness valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Boolean loudness = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            loudness = new BooleanDatatype().valueOf(attribute.getValue());
    }
    return channel != null && loudness != null ? new ChannelLoudness(channel, loudness) : null;
}
 
Example #8
Source File: EventedValueChannelMute.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ChannelMute valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Boolean mute = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            mute = new BooleanDatatype().valueOf(attribute.getValue());
    }
    return channel != null && mute != null ? new ChannelMute(channel, mute) : null;
}
 
Example #9
Source File: AbstractAudioRenderingControl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void appendCurrentState(LastChange lc, UnsignedIntegerFourBytes instanceId) throws Exception {
    for (Channel channel : getCurrentChannels()) {
        String channelString = channel.name();
        lc.setEventedValue(
                instanceId,
                new RenderingControlVariable.Mute(new ChannelMute(channel, getMute(instanceId, channelString))),
                new RenderingControlVariable.Loudness(new ChannelLoudness(channel, getLoudness(instanceId, channelString))),
                new RenderingControlVariable.Volume(new ChannelVolume(channel, getVolume(instanceId, channelString).getValue().intValue())),
                new RenderingControlVariable.VolumeDB(new ChannelVolumeDB(channel, getVolumeDB(instanceId, channelString))),
                new RenderingControlVariable.PresetNameList(PresetName.FactoryDefaults.name())
        );
    }
}
 
Example #10
Source File: EventedValueChannelVolume.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected ChannelVolume valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Integer volume = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            volume = (new UnsignedIntegerTwoBytesDatatype()
                    .valueOf(attribute.getValue()))
                    .getValue().intValue(); // Java is fun!
    }
    return channel != null && volume != null ? new ChannelVolume(channel, volume) : null;
}
 
Example #11
Source File: EventedValueChannelMute.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected ChannelMute valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
    Channel channel = null;
    Boolean mute = null;
    for (Map.Entry<String, String> attribute : attributes) {
        if (attribute.getKey().equals("channel"))
            channel = Channel.valueOf(attribute.getValue());
        if (attribute.getKey().equals("val"))
            mute = new BooleanDatatype().valueOf(attribute.getValue());
    }
    return channel != null && mute != null ? new ChannelMute(channel, mute) : null;
}
 
Example #12
Source File: AbstractAudioRenderingControl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void appendCurrentState(LastChange lc, UnsignedIntegerFourBytes instanceId) throws Exception {
    for (Channel channel : getCurrentChannels()) {
        String channelString = channel.name();
        lc.setEventedValue(
                instanceId,
                new RenderingControlVariable.Mute(new ChannelMute(channel, getMute(instanceId, channelString))),
                new RenderingControlVariable.Loudness(new ChannelLoudness(channel, getLoudness(instanceId, channelString))),
                new RenderingControlVariable.Volume(new ChannelVolume(channel, getVolume(instanceId, channelString).getValue().intValue())),
                new RenderingControlVariable.VolumeDB(new ChannelVolumeDB(channel, getVolumeDB(instanceId, channelString))),
                new RenderingControlVariable.PresetNameList(PresetName.FactoryDefaults.name())
        );
    }
}
 
Example #13
Source File: AbstractAudioRenderingControl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected Channel getChannel(String channelName) throws RenderingControlException {
    try {
        return Channel.valueOf(channelName);
    } catch (IllegalArgumentException ex) {
        throw new RenderingControlException(ErrorCode.ARGUMENT_VALUE_INVALID, "Unsupported audio channel: " + channelName);
    }
}
 
Example #14
Source File: AbstractAudioRenderingControl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected Channel getChannel(String channelName) throws RenderingControlException {
    try {
        return Channel.valueOf(channelName);
    } catch (IllegalArgumentException ex) {
        throw new RenderingControlException(ErrorCode.ARGUMENT_VALUE_INVALID, "Unsupported audio channel: " + channelName);
    }
}
 
Example #15
Source File: ChannelVolumeDB.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Channel getChannel() {
    return channel;
}
 
Example #16
Source File: GetVolume.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public GetVolume(UnsignedIntegerFourBytes instanceId, Service service) {
    super(new ActionInvocation(service.getAction("GetVolume")));
    getActionInvocation().setInput("InstanceID", instanceId);
    getActionInvocation().setInput("Channel", Channel.Master.toString());
}
 
Example #17
Source File: GetMute.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public GetMute(UnsignedIntegerFourBytes instanceId, Service service) {
    super(new ActionInvocation(service.getAction("GetMute")));
    getActionInvocation().setInput("InstanceID", instanceId);
    getActionInvocation().setInput("Channel", Channel.Master.toString());
}
 
Example #18
Source File: ChannelLoudness.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public ChannelLoudness(Channel channel, Boolean loudness) {
    this.channel = channel;
    this.loudness = loudness;
}
 
Example #19
Source File: ChannelLoudness.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Channel getChannel() {
    return channel;
}
 
Example #20
Source File: ChannelVolumeDB.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public ChannelVolumeDB(Channel channel, Integer volumeDB) {
    this.channel = channel;
    this.volumeDB = volumeDB;
}
 
Example #21
Source File: AudioRenderingControl.java    From HPlayer with Apache License 2.0 4 votes vote down vote up
@Override
protected Channel[] getCurrentChannels() {
    return new Channel[0];
}
 
Example #22
Source File: ChannelVolume.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public ChannelVolume(Channel channel, Integer volume) {
    this.channel = channel;
    this.volume = volume;
}
 
Example #23
Source File: ChannelVolume.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Channel getChannel() {
    return channel;
}
 
Example #24
Source File: ChannelMute.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public ChannelMute(Channel channel, Boolean mute) {
    this.channel = channel;
    this.mute = mute;
}
 
Example #25
Source File: ChannelMute.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Channel getChannel() {
    return channel;
}
 
Example #26
Source File: AudioRenderingControl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void checkChannel(String channelName) throws RenderingControlException {
    if (!getChannel(channelName).equals(Channel.Master)) {
        throw new RenderingControlException(ErrorCode.ARGUMENT_VALUE_INVALID, "Unsupported audio channel: " + channelName);
    }
}
 
Example #27
Source File: AudioRenderingControl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected Channel[] getCurrentChannels() {
    return new Channel[] {
            Channel.Master
    };
}
 
Example #28
Source File: SetMute.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public SetMute(UnsignedIntegerFourBytes instanceId, Service service, boolean desiredMute) {
    super(new ActionInvocation(service.getAction("SetMute")));
    getActionInvocation().setInput("InstanceID", instanceId);
    getActionInvocation().setInput("Channel", Channel.Master.toString());
    getActionInvocation().setInput("DesiredMute", desiredMute);
}
 
Example #29
Source File: SetMute.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public SetMute(UnsignedIntegerFourBytes instanceId, Service service, boolean desiredMute) {
    super(new ActionInvocation(service.getAction("SetMute")));
    getActionInvocation().setInput("InstanceID", instanceId);
    getActionInvocation().setInput("Channel", Channel.Master.toString());
    getActionInvocation().setInput("DesiredMute", desiredMute);
}
 
Example #30
Source File: SetVolume.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public SetVolume(UnsignedIntegerFourBytes instanceId, Service service, long newVolume) {
    super(new ActionInvocation(service.getAction("SetVolume")));
    getActionInvocation().setInput("InstanceID", instanceId);
    getActionInvocation().setInput("Channel", Channel.Master.toString());
    getActionInvocation().setInput("DesiredVolume", new UnsignedIntegerTwoBytes(newVolume));
}