我正在开发一个基于WPF的应用程序,它必须在执行期间播放一些视频.为了做到这一点,我正在使用MediaElement该类,但是在我使用我的应用程序进行第一次测试之后,我发现我试图播放的一些视频不受Media Element类支持,因为我错过了正确的编解码器.安装丢失的编解码器后一切正常.
问题是我的客户的机器也可能缺少编解码器,在这种情况下我想显示某种消息,说缺少编解码器,这样就可以快速解决这个问题,但是当我在看MediaElement课时,我没有找不到任何说明为什么给定视频没有播放的属性.实际上,从我所看到的MediaElement情况来看,当它试图播放的视频不是正确的格式时,它甚至没有抛出异常,也没有状态变量说它是或者没有播放视频.
因此,我想知道是否有任何方法可以在运行时以编程方式发现给定视频是否可以播放MediaElement.
我正在使用Visual Studio 2010创建一个C++程序,它应该在我的机器的后台运行.
因此,当我启动它时,我不应该在运行时看到CMD屏幕.我怎样才能做到这一点?我是否必须使用Win32 API或普通的C++程序就足够了?
请注意,我的程序根本没有GUI.
我正在Go中编写一个程序,它应该打开一个可移植的浏览器到一个给定的页面并监视它,这样如果浏览器关闭,它应该自动重新打开.程序退出时也应该关闭浏览器.
到目前为止,我已经设法在用户关闭浏览器时重新打开浏览器,但是我无法关闭它.
这是我的代码:
package browser
import (
"fmt"
"os/exec"
log "github.com/sirupsen/logrus"
)
type iBrowserHandler interface {
Start(processListener chan bool) error
Stop() error
KillProcess() error
}
type browserHandler struct {
cmd *exec.Cmd
pathToChromium string
pdvEndpoint string
}
func newBrowserHandler(pathToChromium string, pdvEndpoint string) iBrowserHandler {
b := &browserHandler{}
b.pathToChromium = pathToChromium
b.pdvEndpoint = pdvEndpoint
return b
}
func (b *browserHandler) Start(processListener chan bool) error {
endpoint := fmt.Sprintf("--app=%s", b.pdvEndpoint)
b.cmd = exec.Command(b.pathToChromium, endpoint, "--kiosk")
err := b.cmd.Run()
if err != nil { …Run Code Online (Sandbox Code Playgroud) 我有一个Angular 8应用程序,该应用程序托管在Firebase上,并通过以下方式在客户端运行:Go-Astilectron(Astilectron 0.30和Electron 4.0.1)。
问题是我在某些客户端中遇到了以下错误(此错误正好在加载Angular代码时发生,因此Astilectron仅显示空白页):
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
main-es2015.5a90aaf45a8347384655.js:1
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Run Code Online (Sandbox Code Playgroud)
在某些情况下,我们设法通过重新加载页面来解决此问题,但在其他情况下,无论我做什么,该页面都不会加载。
我进行了一些研究,发现这可能与注册服务工作者的应用程序有关,但这不是我的情况。
另外,由于我使用Firebase Hosting服务静态站点,因此未进行任何MIME配置。
谁能帮我?
我正在尝试使用docker和在 Windows 10 上配置环境docker-compose,但我无法从 docker 注册表中提取图像。
每次运行时docker-compose up -d,都会出现以下错误:
Pulling queue (redis:)...
ERROR: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.65.1:53: read udp 192.168.65.3:36785->192.168.65.1:53: i/o timeout
Run Code Online (Sandbox Code Playgroud)
我在网上环顾四周,有些人建议将 DNS 服务器设置为固定服务器:8.8.8.8. 我这样做了,但我仍然有问题。
更新
根据@kaki 的建议,我查看了我的主机文件,看到了几个关于 docker 的条目:
100.114.69.30 host.docker.internal
100.114.69.30 gateway.docker.internal
host.docker.internal
gateway.docker.internal
192.168.1.103 host.docker.internal
192.168.1.103 gateway.docker.internal
# Added by Docker Desktop
192.168.0.11 host.docker.internal
192.168.0.11 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# …Run Code Online (Sandbox Code Playgroud) 我正在使用Go创建一个应用,并且正在尝试使用该ListenAndServeTLS功能启动https服务器。这是我的代码:
func StartServer() {
defer config.CapturePanic()
c := config.GetInstance()
serverAddress := fmt.Sprintf(":%s", c.GetConfig().ServerPort)
server := http.Server{Addr: serverAddress}
log.Info("Starting local server")
http.HandleFunc("/", login.Handler)
http.HandleFunc("/login", login.Handler)
http.HandleFunc("/settings", settings.Handler)
//cert, _ := data.Asset("my-cert.pem")
//key, _ := data.Asset("my-key.pem")
err := server.ListenAndServeTLS("my-cert.crt", "my-cert.key")
if err != nil {
log.WithError(err).Fatal("Error stopping local server")
}
}
Run Code Online (Sandbox Code Playgroud)
问题是我想将我的证书及其密钥嵌入我的可执行文件中,然后将它们server.ListeAndServeTLS作为字符串或字节数组传递给函数。但是,此函数不采用这些类型的参数。还有另一种方法吗?
注意:我知道在客户端应用程序中嵌入私钥是一种不好的做法,但是我在这里试图做的只是创建将以托管的配置网页https://localhost:8080。
我正在尝试反序列化 XML,但是我在使用 List 对象时遇到了很多问题。
XML 如下:
<EntriesSerialize>
<Entries>
<Entry file="myFile"
value="2000" />
<Entry file="myFile"
value="400" />
<Entry file="myFile"
value="200" />
</Entries>
</EntriesSerialize>
Run Code Online (Sandbox Code Playgroud)
我的课程是:
[XmlType("Entry")]
public class Entry
{
public Entry()
{
}
[XmlAttribute("file")]
public string File { get; set; }
[XmlAttribute("value")]
public string Value { get; set; }
}
[XmlType("EntriesSerialize")]
public class EntriesSerialize
{
public EntriesSerialize()
{
EntriesList = new List<Entry>();
}
[XmlElement("Entries")]
public List<Entry> EntriesList { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我用来反序列化这个 XML 的代码是:
public static T Deserialize<T>(string content)
{ …Run Code Online (Sandbox Code Playgroud) 我正在使用Angular 4创建一个前端,我遇到了一个奇怪的错误.每当我执行以下代码时:
private createProductTree(productData: Map<number, any>): Map<number, Node> {
const productTree = new Map<number, Node>();
// Iterate over menu-item objects.
for (let key of productData.keys()) {
const product = productData.get(key);
if (product.type === 'menu-item') {
const node = new Node(product);
productTree.set(key, node);
}
}
return productTree;
}
Run Code Online (Sandbox Code Playgroud)
我得到以下错误:Type 'IterableIterator<number>' is not an array type or a string type.在for (... of ...)行.
我不确定我做错了什么.该for代码是一样的一个,我看到这里.
我正在使用@ngrx/store和@ngrx/effect开发一个Angular 4应用程序,我正在尝试为我的效果编写一些单元测试.
我的一个效果应该是使用服务从后端获取一些数据.从后端检索值后,应每隔一段时间触发此效果,以生成轮询效果并更新本地数据.
由于轮询间隔是在我的应用程序状态配置的,我希望能够模拟状态存储,以便我可以在测试期间更改它.
这是我的SPEC:
describe('Order Effects', () => {
let actions: Observable<any>;
let effects: OrderEffect;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
StoreModule.forRoot({ orders: ordersReducer })
],
providers: [
OrderEffect,
provideMockActions(() => actions),
{ provide: OrderService, useValue: jasmine.createSpyObj('orderService', ['getAllOrders']) }
]
});
effects = TestBed.get(OrderEffect);
});
it('should load orders and call load orders complete action', () => {
const mockData = [{ id: 1 }, { id: 2 }, { id: 3 }];
const orderService = TestBed.get(OrderService);
orderService.getAllOrders.and.returnValue(Observable.of(mockData));
actions = …Run Code Online (Sandbox Code Playgroud) 我正在使用 Pipenv 创建一个 Python 项目,并且我有以下 Pipfile:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
black = "==19.10b0"
pylint = "==2.4.4"
pytest = "==5.3.1"
pytest-mock = "==1.13.0"
pytest-flask = "==0.15.0"
[packages]
python-decouple = "==3.3"
pytz = "*"
Flask = "==1.1.1"
Flask-RESTful = "==0.3.7"
uWSGI = "==2.0.18"
[requires]
python_version = "3.8"
Run Code Online (Sandbox Code Playgroud)
我的问题是该uWSGI软件包仅适用于 Linux,而我使用的是 Windows。因此,每当我运行pipenv install它时,它都会因此而失败。有没有办法告诉 Pipenv 仅在 Windows 环境中忽略此包的安装?
更新
这是命令的结果: pipenv lock -r
Pipfile.lock (e1b4e4) out of date, updating to (5696f6)…
Locking [dev-packages] dependencies… …Run Code Online (Sandbox Code Playgroud) 我正在为我的ASP .NET MVC Controller类创建一些单元测试,我遇到了一些非常奇怪的错误:
我的控制器代码如下:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(JournalViewModel journal)
{
var selectedJournal = Mapper.Map<JournalViewModel, Journal>(journal);
var opStatus = _journalRepository.DeleteJournal(selectedJournal);
if (!opStatus.Status)
throw new System.Web.Http.HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
我的测试代码如下:
[TestMethod]
public void Delete_Journal()
{
// Arrange
// Simulate PDF file
HttpPostedFileBase mockFile = Mock.Create<HttpPostedFileBase>();
Mock.Arrange(() => mockFile.FileName).Returns("Test.pdf");
Mock.Arrange(() => mockFile.ContentLength).Returns(255);
// Create view model to send.
JournalViewModel journalViewModel = new JournalViewModel();
journalViewModel.Id = 1;
journalViewModel.Title = "Test";
journalViewModel.Description = "TestDesc";
journalViewModel.FileName = "TestFilename.pdf";
journalViewModel.UserId = 1;
journalViewModel.File = …Run Code Online (Sandbox Code Playgroud) 我是 React 和 Redux 的新手,我正在使用 Typescript 制作一个小项目。我创建了我的第一个减速器和操作,但我有一个问题:每当我尝试访问有效负载的内容时,我都会得到一个Type error: property X does not exist in type.
行动:
import { Action } from 'redux';
export const LOGIN_ACTION = 'login';
export const LOGIN_SUCCESS_ACTION = 'login-sucesss';
export const LOGIN_FAILED_ACTION = 'login-failed';
export interface LoginAction extends Action {
type: string;
payload: {
username: string;
password: string;
};
}
export function login(username: string, password: string): LoginAction {
return {
type: LOGIN_ACTION,
payload: { username, password },
};
}
export interface LoginSuccessAction extends Action { …Run Code Online (Sandbox Code Playgroud) angular ×3
c# ×3
go ×2
typescript ×2
unit-testing ×2
.net-4.0 ×1
asp.net-mvc ×1
automapper ×1
c++ ×1
docker ×1
electron ×1
firebase ×1
jasmine ×1
javascript ×1
justmock ×1
mediaelement ×1
pipenv ×1
python ×1
react-redux ×1
reactjs ×1
redux ×1
security ×1
windows ×1
wpf ×1
xml ×1