Android的 - 禁用HDMIAndroid、HDMI

2023-09-07 14:54:14 作者:呼你一脸姨妈巾

我的一个Android的项目,需要不时2路HDMI输入之间切换到时候,可能每分钟一次。一个HDMI输入是来自Android设备的HDMI输出,一个来自外部的,不可控制的来源。

One of my Android projects needs to switch between 2 HDMI inputs from time to time, possibly once a minute. One HDMI input is from an android device's HDMI output and one is from an external, uncontrollable source.

我发现了一个HDMI开关时,信号变得可用2源之间的自动切换。我的问题是,有没有办法来临时(例如一分钟)把我的Andr​​oid设备的HDMI输出,使得交换机可以自动使用第二个HDMI输入?然后,我需要恢复HDMI输出,使交换机将显示我的设备的HDMI输出。

I found an HDMI switch that automatically switches between 2 sources when the signal becomes available. My question is, is there a way to temporarily (one minute for example) cut HDMI output of my Android device so that the switch can automatically use the second HDMI input? Then, I need to restore the HDMI output so that the switch will show my device's HDMI output.

我发现这个question但我不知道我需要禁用HDMI输出,而是重定向以某种方式显示,并在1分钟后其恢复。

I found this question but I am not sure I need to disable HDMI output but rather redirect the display in some way and restore it back after 1 minute.

更新

我要开始一个赏金所以我会澄清我的要求一点:我有2个端口的HDMI功能的​​电视。我的Andr​​oid设备连接端口1,另一个设备上的端口连接2.将电视自动切换到有信号的下一个HDMI端口。

I want to start a bounty so I will clarify my request a bit: I have an HDMI-enabled TV with 2 ports. My android device is connected on port 1, another device is connected on port 2. The TV automatically switches to the next HDMI port that has signal.

例如,如果HDMI1和HDMI2有信号,我把我的电视上HDMI1。当第一个装置关闭了HDMI输出,电视将切换到HDMI2。一段时间(5分钟)的第一装置之后重新打开HDMI1(意味着第一设备启用其HDMI输出)和第二装置关闭的HDMI输出,以便在电视将切换回HDMI1。这样我可以做的视频组合。

For example, if HDMI1 and HDMI2 have signals, I put my TV on HDMI1. When the first device "closes" its HDMI output, the TV will switch to HDMI2. After a while (5 minutes) the first devices "re-opens" HDMI1 (meaning the first device enables its HDMI output) and the second device "closes" its HDMI output so the TV will switch back to HDMI1. This way I can make a mix of videos.

我现在面临的技术难点是如何控制的Andr​​oid系统的HDMI输出。我的Andr​​oid设备只有HDMI接口的显示,它没有一个专门的屏幕。

The technical difficulty I am facing is how to control the HDMI output in Android systems. My Android device only has HDMI interface for displaying, it doesn't have a dedicated screen.

足够接近我所需要的唯一的东西是this SO帖子,但它并没有真正在我的情况有所帮助。

The only stuff close enough to what I need is this SO post, but it doesn't really help in my case.

推荐答案

最好的方法是使用使用set相关与displayID的命令,可以让你听的要添加,更改或删除显示器。

The best approach is to use to use the set of commands related to DisplayID, that allows you to listen for displays to be added, changed or removed.

下面是一个简单的例子是怎么回事,变更显示/ HDMI:

Here is a quick example how it goes to change your display/HDMI:

    private final DisplayManager.DisplayListener mDisplayListener =
            new DisplayManager.DisplayListener() {
        @Override
        public void onDisplayAdded(int displayId) {
            Log.d(TAG, "Display #" + displayId + " added.");
            mDisplayListAdapter.updateContents();
        }

        @Override
        public void onDisplayChanged(int displayId) {
            Log.d(TAG, "Display #" + displayId + " changed.");
            mDisplayListAdapter.updateContents();
        }

        @Override
        public void onDisplayRemoved(int displayId) {
            Log.d(TAG, "Display #" + displayId + " removed.");
            mDisplayListAdapter.updateContents();
        }
    };

在这里,如何获得可用来连接所有的HDMI /显示设备:

And here how to get all your HDMI/display devices available to connect:

    protected void onResume() {
        // Be sure to call the super class.
        super.onResume();

        // Update our list of displays on resume.
        mDisplayListAdapter.updateContents();

        // Restore presentations from before the activity was paused.
        final int numDisplays = mDisplayListAdapter.getCount();
        for (int i = 0; i < numDisplays; i++) {
            final Display display = mDisplayListAdapter.getItem(i);
            final PresentationContents contents =
                    mSavedPresentationContents.get(display.getDisplayId());
            if (contents != null) {
                showPresentation(display, contents);
            }
        }
        mSavedPresentationContents.clear();

        // Register to receive events from the display manager.
        mDisplayManager.registerDisplayListener(mDisplayListener, null);
    }

要注销您使用:

//unregisterDisplayListener(DisplayManager.DisplayListener);
@Override
protected void onPause() {
    // Be sure to call the super class.
    super.onPause();

    // Unregister from the display manager.
    mDisplayManager.unregisterDisplayListener(mDisplayListener);

    // Dismiss all of our presentations but remember their contents.
    Log.d(TAG, "Activity is being paused.  Dismissing all active presentation.");
    for (int i = 0; i < mActivePresentations.size(); i++) {
        DemoPresentation presentation = mActivePresentations.valueAt(i);
        int displayId = mActivePresentations.keyAt(i);
        mSavedPresentationContents.put(displayId, presentation.mContents);
        presentation.dismiss();
    }
    mActivePresentations.clear();
}

关于无效HDMI输出,如果最终发生了,只是重新绘制。这应该解决任何 无效,以防它发生。

您可能会发现有用的检查进一步文档。

You might find useful to check further documentation.