locked
how to determine that a mp4 file is a audio/video?

    Question

  • To determining a video/audio, I try to use MFCreateSourceReaderFromURL() to get a source reader, and then use GetMajorType() to get the type. Unfortunately, I can not access a file by specific path. ex: C:\\Users\\xxx\\Pictures\\m.mp3. Is there another way to determine that a mp4 file is a audio/video? Thanks.

    Monday, July 23, 2012 2:33 AM

Answers

  • Hello Mandy,

    When using the file picker or know folder the URI will not have permission to access the file. The user must explicitly give you access via the file picker. The URI returned by the file picker may not be directly accessable either. You must use the file stream retruned by the file picker. You can then feed the input from the byte stream returned by MFCreateSourceReaderFromURL(NULL, &byteStream, &pReader); into the file stream.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, July 25, 2012 3:18 PM
    Moderator

All replies

  • Hello Mandy,

    I'm not sure what you are trying to accomplish. There really is no concept of a full file path in the Metro environment. However you can use the file picker to get a stream object and then convert that into a stream object that the source reader can use.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, July 25, 2012 12:06 AM
    Moderator
  • Actually,I insert the m.mp3 file into my project(App12) and use the specific path : "C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\App12\\Debug\\App12\\AppX\\m.mp3" as a parameter of MFCreateSourceReaderFromURL() .

    LPCWSTR str2= L"C:\\Users\\user\\Documents\\Visual Studio 2012\\Projects\\App12\\Debug\\App12\\AppX\\m.mp3";

    hr = MFCreateSourceReaderFromURL(str2, NULL, &pReader);


    That means the m.mp3 and App12.exe are in the same folder. It can access this file and get a source reader successfully.

    However, when I use "C:\\Users\\xxx\\Pictures\\m.mp3" even from the Knownfolder(ex: Picture ,Document..), it does not work. I don't know why. In the Metro environment, app can access the file in the location which is declared in manifest, does it?


    • Edited by Mandy1205 Wednesday, July 25, 2012 12:35 PM add code
    Wednesday, July 25, 2012 12:24 PM
  • Hello Mandy,

    When using the file picker or know folder the URI will not have permission to access the file. The user must explicitly give you access via the file picker. The URI returned by the file picker may not be directly accessable either. You must use the file stream retruned by the file picker. You can then feed the input from the byte stream returned by MFCreateSourceReaderFromURL(NULL, &byteStream, &pReader); into the file stream.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, July 25, 2012 3:18 PM
    Moderator
  • Also, ensure that you have declared "Pictures Library" in your app manifest.  This will allow access to the current user's pictures library.
    Thursday, July 26, 2012 5:04 PM