我想在我的网站背景上嵌入一个YouTube视频.我有这个工作,它是响应,除了当我的嵌入视频是宽屏(16:9),但我的视口是例如方形(1:1),它创建黑色边框,以补偿剩余的空间.

我想知道是否有裁剪视频的选项,以便视频的"中心"始终在屏幕上,就像上面的示例图片一样.剩下的部分将被切断.我认为图像的CSS相当于background-size: cover;.
这是我现在的代码.尝试使您的视口正方形,您将看到黑色边框.它也可以在jsfiddle中使用.
<html>
<head>
<style>
body,html{ margin:0; padding:0; height:100%;}
div.bg_utube {
position: fixed;
z-index: -99999;
-webkit-user-select: none;
user-select: none;
width: 100%;
height: 100%;
}
#player{
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="bg_utube">
<div id="player"></div>
<script>
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
var video_id = 'JQ7a_8psCn0';
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: …Run Code Online (Sandbox Code Playgroud) CMake 无法为我找到 OpenSSL。Brew 的 OpenSSL 位于/usr/local/Cellar/openssl/1.0.2s/. 我使用的是 macOS Catalina。
我的CMakeLists.txt看起来像这样:
[...]
set(OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/1.0.2s)
find_package(OpenSSL REQUIRED)
target_include_directories(myapp PUBLIC ${OPENSSL_INCLUDE_DIR})
message(STATUS "OpenSSL: Version ${OPENSSL_VERSION}")
message(STATUS "OpenSSL: include dir at ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL: libraries at ${OPENSSL_LIBRARIES} ${OPENSSL_SSL_LIBRARIES}")
[...]
target_link_libraries(myapp
${CMAKE_DL_LIBS}
${OPENSSL_LIBRARIES}
${OPENSSL_SSL_LIBRARIES}
Qt5::Core
)
Run Code Online (Sandbox Code Playgroud)
输出:
-- OpenSSL: Version 1.0.2s
-- OpenSSL: include dir at /usr/local/Cellar/openssl/1.0.2s/include
-- OpenSSL: libraries at /usr/lib/libssl.dylib;/usr/lib/libcrypto.dylib /usr/lib/libssl.dylib
Run Code Online (Sandbox Code Playgroud)
那么 CMake 找到了正确的包含目录,但这些库是从我的系统安装的 OpenSSL 中获取的?即使我OPENSSL_ROOT_DIR按照文档指定。
为什么找不到这些文件?
/usr/local/Cellar/openssl/1.0.2s/lib/libcrypto.a
/usr/local/Cellar/openssl/1.0.2s/lib/pkgconfig/libssl.pc
/usr/local/Cellar/openssl/1.0.2s/lib/pkgconfig/libcrypto.pc
/usr/local/Cellar/openssl/1.0.2s/lib/libssl.dylib
/usr/local/Cellar/openssl/1.0.2s/lib/libcrypto.1.0.0.dylib
/usr/local/Cellar/openssl/1.0.2s/lib/libcrypto.dylib
/usr/local/Cellar/openssl/1.0.2s/lib/libssl.1.0.0.dylib
/usr/local/Cellar/openssl/1.0.2s/lib/libssl.a …Run Code Online (Sandbox Code Playgroud) 我怎样才能将延迟的“扔”到反应堆中,以便在路上的某个地方进行处理?
情况
我有 2 个程序在本地主机上运行。
当有人连接到 webservice 时,它需要向 jsonrpc 服务发送一个查询,等待它返回一个结果,然后在用户的 web 浏览器中显示结果(返回 jsonrpc 调用的值)。
我似乎无法弄清楚如何返回延迟的 jsonrpc 调用的值。当我使用浏览器访问 Web 服务时,我收到一个 HTML 500 错误代码(没有返回任何字节)和值:< Deferred at 0x3577b48 >。
它返回延迟对象而不是回调的实际值。
在询问之前已经环顾了几个小时并尝试了很多不同的变化。
from txjsonrpc.web.jsonrpc import Proxy
from twisted.web import resource
from twisted.web.server import Site
from twisted.internet import reactor
class Rpc():
def __init__(self, child):
self._proxy = Proxy('http://127.0.0.1:30301/%s' % child)
def execute(self, function):
return self._proxy.callRemote(function)
class Server(resource.Resource):
isLeaf = True
def render_GET(self, request):
rpc = Rpc('test').execute('test')
def test(result):
return '<h1>%s</h1>' % …Run Code Online (Sandbox Code Playgroud)