html5 видео не воспроизводится с помощью awesomium

Я не могу получить Awesomium 1.7.0 для воспроизведения html5-видео (формат webm), даже если примеры проектов идут вместе с SDK (sample_gdi).
образец страницы: http://www.webmfiles.org/demo-files/

Похоже, видео кадры правильно загружен, но игрок застрял на первом кадре. Хотя, если я перемещаю индикатор выполнения вручную, я могу просматривать видеокадры …

Я пробовал как с окном webViewType, так и вне экрана, а также с включенными enable_gpu_acceleration и enable_web_gl, но каждый раз безуспешно …

Мои спецификации: VS2010, Windows 7

Есть идеи? Спасибо!!

Код из примера проекта «Sample_gdi», автоматически устанавливаемый установщиком Awesomium 1.7.0, доступный в C: \ Users [пользователь] \ Documents \ Visual Studio 2010 \ Projects \ Awesomium \ 1.7.0.5 \ BuildSamples \ BuildSamples.sln :

Main.cc

#include "../common/application.h"#include "../common/view.h"#include <Awesomium/WebCore.h>
#include <Awesomium/STLHelpers.h>
#ifdef _WIN32
#include <Windows.h>
#endif

using namespace Awesomium;

class GDISample : public Application::Listener {
Application* app_;
View* view_;
public:
GDISample()
: app_(Application::Create()),
view_(0) {
app_->set_listener(this);
}

virtual ~GDISample() {
if (view_)
app_->DestroyView(view_);
if (app_)
delete app_;
}

void Run() {
app_->Run();
}

// Inherited from Application::Listener
virtual void OnLoaded() {
view_ = View::Create(800, 600);
view_->web_view()->LoadURL(WebURL(WSLit("http://www.google.com")));
}

// Inherited from Application::Listener
virtual void OnUpdate() {
}

// Inherited from Application::Listener
virtual void OnShutdown() {
}
};

int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, wchar_t*,
int nCmdShow) {

GDISample sample;
sample.Run();

return 0;
}

application_win.cc

#include "application.h"#include "view.h"#include <Awesomium/WebCore.h>
#include <Awesomium/STLHelpers.h>
#include <string>

using namespace Awesomium;

class ApplicationWin : public Application {
bool is_running_;
public:
ApplicationWin() {
is_running_ = true;
listener_ = NULL;
web_core_ = NULL;
}

virtual ~ApplicationWin() {
if (listener())
listener()->OnShutdown();

if (web_core_)
web_core_->Shutdown();
}

virtual void Run() {
Load();

// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) && is_running_) {
web_core_->Update();
TranslateMessage(&msg);
DispatchMessage(&msg);
if (listener())
listener()->OnUpdate();
}
}

virtual void Quit() {
is_running_ = false;
}

virtual void Load() {
WebConfig config;
web_core_ = WebCore::Initialize(config);

if (listener())
listener()->OnLoaded();
}

virtual View* CreateView(int width, int height) {
return View::Create(width, height);
}

virtual void DestroyView(View* view) {
delete view;
}

virtual void ShowMessage(const char* message) {
std::wstring message_str(message, message + strlen(message));
MessageBox(0, message_str.c_str(), message_str.c_str(), NULL);
}
};

Application* Application::Create() {
return new ApplicationWin();
}

view_win.cc

#include "view.h"#include <Awesomium/WebCore.h>
#include <Awesomium/STLHelpers.h>
#include <vector>

class ViewWin;

static bool g_is_initialized = false;
static std::vector<ViewWin*> g_active_views_;
const wchar_t szWindowClass[] = L"ViewWinClass";
const wchar_t szTitle[] = L"Application";
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

using namespace Awesomium;

class ViewWin : public View,
public WebViewListener::View {
public:
ViewWin(int width, int height) {
PlatformInit();
WebPreferences webPref;
WebSession *session =  WebCore::instance()->CreateWebSession(ToWebString(""),webPref);
web_view_ = WebCore::instance()->CreateWebView(width,
height,
session,
Awesomium::kWebViewType_Window);

web_view_->set_view_listener(this);

// Create our WinAPI Window
HINSTANCE hInstance = GetModuleHandle(0);
hwnd_ = CreateWindow(szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
width + 20,
height + 40,
NULL,
NULL,
hInstance,
NULL);

if (!hwnd_)
exit(-1);

web_view_->set_parent_window(hwnd_);

ShowWindow(hwnd_, SW_SHOWNORMAL);
UpdateWindow(hwnd_);

SetTimer (hwnd_, 0, 15, NULL );

g_active_views_.push_back(this);
}

virtual ~ViewWin() {
for (std::vector<ViewWin*>::iterator i = g_active_views_.begin();
i != g_active_views_.end(); i++) {
if (*i == this) {
g_active_views_.erase(i);
break;
}
}

web_view_->Destroy();
}

HWND hwnd() { return hwnd_; }

static void PlatformInit() {
if (g_is_initialized)
return;

WNDCLASSEX wc;

wc.cbSize        = sizeof(WNDCLASSEX);
wc.style         = 0;
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = GetModuleHandle(0);
wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName  = NULL;
wc.lpszClassName = szWindowClass;
wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc)) {
exit(-1);
}

g_is_initialized = true;
}

static ViewWin* GetFromHandle(HWND handle) {
for (std::vector<ViewWin*>::iterator i = g_active_views_.begin();
i != g_active_views_.end(); i++) {
if ((*i)->hwnd() == handle) {
return *i;
}
}

return NULL;
}

// Following methods are inherited from WebViewListener::View

virtual void OnChangeTitle(Awesomium::WebView* caller,
const Awesomium::WebString& title) {
std::string title_utf8(ToString(title));
std::wstring title_wide(title_utf8.begin(), title_utf8.end());

SetWindowText(hwnd_, title_wide.c_str());
}

virtual void OnChangeAddressBar(Awesomium::WebView* caller,
const Awesomium::WebURL& url) { }

virtual void OnChangeTooltip(Awesomium::WebView* caller,
const Awesomium::WebString& tooltip) { }

virtual void OnChangeTargetURL(Awesomium::WebView* caller,
const Awesomium::WebURL& url) { }

virtual void OnChangeCursor(Awesomium::WebView* caller,
Awesomium::Cursor cursor) { }

virtual void OnChangeFocus(Awesomium::WebView* caller,
Awesomium::FocusedElementType focused_type) { }

virtual void OnShowCreatedWebView(Awesomium::WebView* caller,
Awesomium::WebView* new_view,
const Awesomium::WebURL& opener_url,
const Awesomium::WebURL& target_url,
const Awesomium::Rect& initial_pos,
bool is_popup) { }

virtual void OnAddConsoleMessage(Awesomium::WebView* caller,
const Awesomium::WebString& message,
int line_number,
const Awesomium::WebString& source) { }

protected:
HWND hwnd_;
};

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
ViewWin* view = ViewWin::GetFromHandle(hWnd);

switch (message) {
case WM_COMMAND:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
case WM_TIMER:
break;
case WM_SIZE:
view->web_view()->Resize(LOWORD(lParam), HIWORD(lParam));
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_QUIT:
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

View* View::Create(int width, int height) {
return new ViewWin(width, height);
}

../common/application.h

#ifndef COMMON_APPLICATION_H_
#define COMMON_APPLICATION_H_

class View;

namespace Awesomium {
class WebCore;
}

// Common class that sets up an application, creates the WebCore, handles
// the Run loop, and abstracts platform-specific details.
class Application {
public:
// Listener interface to be used to handle various application events.
class Listener {
public:
virtual ~Listener() {}

// Event is fired when app (and WebCore) have been loaded.
virtual void OnLoaded() = 0;

// Event is fired for each iteration of the Run loop.
virtual void OnUpdate() = 0;

// Event is fired when the app is shutting down.
virtual void OnShutdown() = 0;
};

virtual ~Application() {}

// Platform-specific factory constructor
static Application* Create();

// Begin the Run loop.
virtual void Run() = 0;

// Ends the Run loop.
virtual void Quit() = 0;

// Create a platform-specific, windowed View
virtual View* CreateView(int width, int height) = 0;

// Destroy a View
virtual void DestroyView(View* view) = 0;

// Show a modal message box
virtual void ShowMessage(const char* message) = 0;

// Get the WebCore
virtual Awesomium::WebCore* web_core() { return web_core_; }

// Get the Listener.
Listener* listener() { return listener_; }

// Set the Listener for various app events.
void set_listener(Listener* listener) { listener_ = listener; }

protected:
Application() { }

virtual void Load() = 0;

Listener* listener_;
Awesomium::WebCore* web_core_;
};

#endif  // COMMON_APPLICATION_H_

../common/view.h

#ifndef COMMON_VIEW_H_
#define COMMON_VIEW_H_

namespace Awesomium {
class WebView;
}

// Common class that implements a windowed WebView, handles all input/display,
// and abstracts away all the platform-specific details.
class View {
public:
virtual ~View() {}

// Platform-specific constructor
static View* Create(int width, int height);

// Get the associated WebView
Awesomium::WebView* web_view() { return web_view_; }

protected:
View() { }

Awesomium::WebView* web_view_;
};

#endif  // COMMON_VIEW_H_

0

Решение

Похоже, я не смог воспроизвести ошибку при развертывании на других компьютерах.
На моем компьютере должно быть что-то сломанное, что мешает awesomium правильно воспроизводить видео html5 …

0

Другие решения

Я потратил целый день на эту проблему, и для меня это оказалось проблемой со звуковым соединением. Мне пришлось использовать кабель HDMI или подключить динамики к компьютеру. Как только я это сделал, видео не зависало.
Мои проблемы были вызваны использованием кабеля DVI и отсутствием подключения к моему аудиовыходу.

0