Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[oppo] Fix Play Mode and Disc Type updates #12066

Merged
merged 3 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bundles/org.openhab.binding.oppo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ M3D 3D Show/hide the 2D-to-3D Conversion or 3D adjustment menu
SEH Display the Picture Adjustment menu
DRB Display the Darbee Adjustment menu

#### Extra buttons on UDP models:
#### Extra buttons on UDP models:

HDR Display the HDR selection menu
INH Show on-screen detailed information
RLH Set resolution to Auto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public class OppoBindingConstants {
public static final String QHD = "QHD";
public static final String QHR = "QHR";

public static final String UNKNOW_DISC = "UNKNOW-DISC";
public static final String NO_DISC = "NO DISC";
public static final String LOADING = "LOADING";
public static final String OPEN = "OPEN";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.oppo.internal.communication;

import static org.openhab.binding.oppo.internal.OppoBindingConstants.*;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -54,4 +56,36 @@ public class OppoStatusCodes {
ZOOM_MODE.put("11", "1/3");
ZOOM_MODE.put("12", "1/4");
}

// map to lookup disc type
public static final Map<String, String> DISC_TYPE = new HashMap<>();
static {
mlobstein marked this conversation as resolved.
Show resolved Hide resolved
DISC_TYPE.put("BDMV", "BD-MV");
DISC_TYPE.put("DVDV", "DVD-VIDEO");
DISC_TYPE.put("DVDA", "DVD-AUDIO");
DISC_TYPE.put("SACD", "SACD");
DISC_TYPE.put("CDDA", "CDDA");
DISC_TYPE.put("HDCD", "HDCD");
DISC_TYPE.put("DATA", "DATA-DISC");
DISC_TYPE.put("VCD2", "VCD2");
DISC_TYPE.put("SVCD", "SVCD");
DISC_TYPE.put("UHBD", "UHBD");
DISC_TYPE.put("UNKN", UNKNOW_DISC);
}

// map to lookup playback status
public static final Map<String, String> PLAYBACK_STATUS = new HashMap<>();
static {
PLAYBACK_STATUS.put("DISC", "NO DISC");
PLAYBACK_STATUS.put("LOAD", "LOADING");
PLAYBACK_STATUS.put("OPEN", "OPEN");
PLAYBACK_STATUS.put("CLOS", "CLOSE");
PLAYBACK_STATUS.put("PLAY", "PLAY");
PLAYBACK_STATUS.put("PAUS", "PAUSE");
PLAYBACK_STATUS.put("STOP", "STOP");
PLAYBACK_STATUS.put("HOME", "HOME MENU");
PLAYBACK_STATUS.put("MCTR", "MEDIA CENTER");
PLAYBACK_STATUS.put("SCSV", "SCREEN SAVER");
PLAYBACK_STATUS.put("MENU", "DISC MENU");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,6 @@ public void onNewMessageEvent(OppoMessageEvent evt) {
// example: 0 BD-PLAYER, split off just the number
updateChannelState(CHANNEL_SOURCE, updateData.split(SPACE)[0]);
break;
case UPL:
// we got the playback status update, throw it away and call the query because the text output
// is better
connector.sendCommand(OppoCommand.QUERY_PLAYBACK_STATUS);
break;
case QTK:
// example: 02/10, split off both numbers
String[] track = updateData.split(SLASH);
Expand All @@ -477,10 +472,17 @@ public void onNewMessageEvent(OppoMessageEvent evt) {
updateChannelState(CHANNEL_TOTAL_CHAPTER, chapter[1]);
}
break;
case UPL:
case QPL:
// try to normalize the slightly different responses between UPL and QPL
String playStatus = OppoStatusCodes.PLAYBACK_STATUS.get(updateData);
if (playStatus == null) {
playStatus = updateData;
}

// if playback has stopped, we have to zero out Time, Title and Track info and so on manually
if (NO_DISC.equals(updateData) || LOADING.equals(updateData) || OPEN.equals(updateData)
|| CLOSE.equals(updateData) || STOP.equals(updateData)) {
if (NO_DISC.equals(playStatus) || LOADING.equals(playStatus) || OPEN.equals(playStatus)
|| CLOSE.equals(playStatus) || STOP.equals(playStatus)) {
updateChannelState(CHANNEL_CURRENT_TITLE, ZERO);
updateChannelState(CHANNEL_TOTAL_TITLE, ZERO);
updateChannelState(CHANNEL_CURRENT_CHAPTER, ZERO);
Expand All @@ -489,15 +491,21 @@ public void onNewMessageEvent(OppoMessageEvent evt) {
updateChannelState(CHANNEL_AUDIO_TYPE, UNDEF);
updateChannelState(CHANNEL_SUBTITLE_TYPE, UNDEF);
}
updateChannelState(CHANNEL_PLAY_MODE, updateData);
updateChannelState(CHANNEL_PLAY_MODE, playStatus);

// ejecting the disc does not produce a UDT message, so clear disc type manually
if (OPEN.equals(playStatus) || NO_DISC.equals(playStatus)) {
updateChannelState(CHANNEL_DISC_TYPE, UNKNOW_DISC);
currentDiscType = BLANK;
}

// if switching to play mode and not a CD then query the subtitle type...
// because if subtitles were on when playback stopped, they got nulled out above
// and the subtitle update message ("UST") is not sent when play starts like it is for audio
if (PLAY.equals(updateData) && !CDDA.equals(currentDiscType)) {
if (PLAY.equals(playStatus) && !CDDA.equals(currentDiscType)) {
connector.sendCommand(OppoCommand.QUERY_SUBTITLE_TYPE);
}
currentPlayMode = updateData;
currentPlayMode = playStatus;
break;
case QRP:
updateChannelState(CHANNEL_REPEAT_MODE, updateData);
Expand All @@ -506,16 +514,17 @@ public void onNewMessageEvent(OppoMessageEvent evt) {
updateChannelState(CHANNEL_ZOOM_MODE, updateData);
break;
case UDT:
// we got the disc type status update, throw it away
// and call the query because the text output is better
connector.sendCommand(OppoCommand.QUERY_DISC_TYPE);
case QDT:
currentDiscType = updateData;
updateChannelState(CHANNEL_DISC_TYPE, updateData);
// try to normalize the slightly different responses between UDT and QDT
final String discType = OppoStatusCodes.DISC_TYPE.get(updateData);
currentDiscType = (discType != null ? discType : updateData);
updateChannelState(CHANNEL_DISC_TYPE, (discType != null ? discType : updateData));
mlobstein marked this conversation as resolved.
Show resolved Hide resolved
break;
case UAT:
// we got the audio type status update, throw it away
// and call the query because the text output is better
// wait before sending the command to give the player time to catch up
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
connector.sendCommand(OppoCommand.QUERY_AUDIO_TYPE);
break;
case QAT:
Expand All @@ -524,6 +533,8 @@ public void onNewMessageEvent(OppoMessageEvent evt) {
case UST:
// we got the subtitle type status update, throw it away
// and call the query because the text output is better
// wait before sending the command to give the player time to catch up
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
connector.sendCommand(OppoCommand.QUERY_SUBTITLE_TYPE);
break;
case QST:
Expand Down Expand Up @@ -563,7 +574,7 @@ public void onNewMessageEvent(OppoMessageEvent evt) {
logger.debug("onNewMessageEvent: unhandled key {}, value: {}", key, updateData);
break;
}
} catch (OppoException e) {
} catch (OppoException | InterruptedException e) {
logger.debug("Exception processing event from player: {}", e.getMessage());
}
}
Expand Down