Reputation: 41
I'm using C++ to make my own windows application. There's a .webm video I'd like to play within this application, but I'd like to play it from a URL, as opposed to loading it in from the same directory that I'd put my .exe in. I'm running Windows 10, and just using Emacs and g++ to write/compile.
Does anyone know how I can accomplish this? What include's do I need, is it possible, etc.?
Note: the webm video can be converted to mp4 as well.
For clarification, by "windows application", I mean one of these:
HWND hwnd = CreateWindowEx(0, CLASS_NAME, L"WindowName", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
I'd like to keep using this, since I can make a nice, borderless window with it!
Upvotes: 1
Views: 563
Reputation: 7170
This sample used IMFPMediaPlayer::CreateMediaItemFromURL
, You can directly pass the URL to the function PlayMediaFile
, like:
WCHAR uri[] = L"http://dl5.webmfiles.org/big-buck-bunny_trailer.webm";
hr = PlayMediaFile(hwnd, uri);
Upvotes: 1
Reputation: 192
Use gstreamer with uridecodebin (you need to set uri property). It might be needed to add extra autovideoconvert and/or videoscale element between src and sink.
GstElement *pipeline = gst_pipeline_new ("xvoverlay");
GstElement *src = gst_element_factory_make ("uridecodebin", NULL);
GstElement *sink = gst_element_factory_make ("d3dvideosink", NULL);
g_object_set (G_OBJECT (src), "uri","some_url", NULL);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
gst_element_link (src, sink);
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), (guintptr)hwnd);
GstStateChangeReturn sret = gst_element_set_state (pipeline,
GST_STATE_PLAYING);
If you have gstreamer installed test your setup using:
gst-launch-1.0 uridecodebin uri="http://dl5.webmfiles.org/big-buck-bunny_trailer.webm" ! d3dvideosink
Upvotes: 0