I want to use below code to set the MFMediaEngine Source URL. Below method, is reading from the disk, and converting it into IMByteStream. Now I want to know how can I achieve below code in Visual Win32(c++ code) Project. Is it possible ? If so, please provide some way or hints to do so. Note: Below code is a sample code took from Universal Windows Platform.
using namespace Windows::Storage;
#include <Mfmediaengine.h>
#include <wrl.h>
Microsoft::WRL::ComPtr<IMFMediaEngine> m_mediaEngine;
Microsoft::WRL::ComPtr<IMFMediaEngineEx> m_mediaEngineEx;
void CPlayer::SetBytestream(IRandomAccessStream^ streamHandle)
{
HRESULT hr = S_OK;
ComPtr<IMFByteStream> spMFByteStream = nullptr;
MEDIA::ThrowIfFailed(
MFCreateMFByteStreamOnStreamEx((IUnknown*)streamHandle, &spMFByteStream)
);
MEDIA::ThrowIfFailed(
m_mediaEngineEx->SetSourceFromByteStream(spMFByteStream.Get(), m_bstrURL)
);
return;
}
The UWP apps run sandboxed and have very limited access to the file system. For the most part, they can directly access only their install folder and their application data folder. So you could not directly use the local path as theMedia Engine URL.
As Rob's blog: Skip the path: stick to the StorageFile, you could choose the Files or folders picker to get files and folders. Then, you could read this StorageFile by the IRandomAccessStream
.