Announcement

Collapse
No announcement yet.

WMP createQuery (Pointer Question)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • William Fauver
    replied
    WMP createQuery (Pointer Question)

    Thank you very much! Creating the oQuery DISPATCH was the solution. The server accepts %FALSE, so I didn't need to initialize the variant as you suggested. I also changed vMediaType to "audio" (my error).

    LOCAL vQuery AS VARIANT
    OBJECT CALL oWMPlayer.mediaCollection.createQuery() TO vQuery
    LOCAL vAttribute AS VARIANT
    LOCAL vOperator AS VARIANT
    LOCAL vValue AS VARIANT
    vAttribute = "Author"
    vOperator = "Contains"
    vValue = "Beethoven"
    LOCAL oQuery AS DISPATCH
    oQuery = vQuery
    OBJECT CALL oQuery.addCondition(vAttribute, vOperator, vValue)
    LOCAL vMediaType AS VARIANT
    LOCAL vSortAttribute AS VARIANT
    LOCAL vBool AS VARIANT
    vMediaType = "audio"
    vSortAttribute = EMPTY
    vBool = %FALSE
    LOCAL vPlaylist AS VARIANT
    OBJECT CALL oWMPlayer.mediaCollection.getPlaylistByQuery(vQuery, vMediaType, vSortAttribute, vBool) TO vPlaylist
    OBJECT LET oWMPlayer.currentPlaylist = vPlayList

    Leave a comment:


  • José Roca
    replied
    One of the problems is that using the compound syntax he is creating two queries: an empty one with OBJECT CALL oWMPlayer.mediaCollection.createQuery() TO vQuery, and a second one with OBJECT CALL oWMPlayer.mediaCollection.createQuery().addCondition(vAttribute, vOperator, vValue), which has a condition added but for what he has not a reference.

    Try the following:

    Code:
    OBJECT CALL oWMPlayer.mediaCollection.createQuery() TO vQuery
    DIM oQuery AS DISPATCH ' (or AS IWMPQuery if you are using early binding)
    oQuery = vQuery
    
    vAttribute = "Title"
    vOperator = "Contains"
    vValue = "Blues"
    
    OBJECT CALL oQuery.addCondition(vAttribute, vOperator, vValue)
    
    vMediaType = "Title"
    vSortAttribute = ""
    vBool = %FALSE
    
    OBJECT CALL oWMPlayer.mediaCollection.getPlaylistByQuery(vQuery, vMediaType, vSortAttribute, vBool) TO vPlaylist
    
    OBJECT LET oWMPlayer.currentPlaylist = vPlayList
    Another potential problem can be the boolean parameter (vBool). Some servers just check for true or false, but others are very picky and also check if it is a VT_BOOL variant.

    If this is the case, you can use this function to convert vBool in a VT_BOOL variant:

    Code:
    ' ========================================================================================
    ' Initializes a VARIANT structure with a Boolean value.
    ' ========================================================================================
    FUNCTION PB_InitVariantFromBoolean (BYVAL boolVal AS INTEGER, BYREF pvar AS VARIANT) AS LONG
       LOCAL pv AS VARIANTAPI PTR
       IF VARPTR(pvar) = 0 THEN
          FUNCTION = %E_INVALIDARG
          EXIT FUNCTION
       END IF
       pvar = EMPTY                               ' Make sure is empty to avoid memory leaks
       pv = VARPTR(pvar)                          ' Get the VARIANT address
       @pv.vt = %VT_BOOL                          ' Mark it as containing a boolean value
       @pv.boolVal = IIF&(boolVal <> 0, -1, 0)    ' Set the value
       FUNCTION = %S_OK
    END FUNCTION
    ' ========================================================================================
    Last edited by José Roca; 20 Nov 2008, 07:36 PM.

    Leave a comment:


  • Michael Mattias
    replied
    This should be the doc you want..

    http://msdn.microsoft.com/en-us/library/ms867697.aspx

    Leave a comment:


  • Michael Mattias
    replied
    >vSortAttribute = ""

    I just had similar thing with ADO... instead of null string here, try LET vSortAttribute = EMPTY

    Pointer to query (vQuery) could be VARPTR (vQuery), or it could be the OBJPTR of whatever object the CreateQuery method creates...

    eg
    Code:
    LOCAL oQUeryObject AS (query object interface) 
    OBJECT CALL  ....CreateQuery  to VQuery 
    LET   oQueryObject = vQuery
    pQueryObject = OBJPTR (oQueryObject)
    But I would think just leaving it in the variant returned by CreateQuery would be fine... that is, once you get vQuery, leave it alone.

    Let me guess, no useful error codes?
    Last edited by Michael Mattias; 20 Nov 2008, 06:33 PM.

    Leave a comment:


  • William Fauver
    started a topic WMP createQuery (Pointer Question)

    WMP createQuery (Pointer Question)

    I'm struggling with pointers for WMP createQuery. Any expert advice is welcome.

    '================================================================================
    LOCAL vQuery AS VARIANT 'IN pQuery AS WMPlayerIWMPQuery
    '================================================================================
    LOCAL vAttribute AS VARIANT 'IN bstrAttribute AS STRING
    LOCAL vOperator AS VARIANT 'IN bstrOperator AS STRING
    LOCAL vValue AS VARIANT 'IN bstrValue AS STRING
    '================================================================================
    LOCAL pQuery AS VARIANT PTR 'IN pQuery AS WMPlayerIWMPQuery
    LOCAL vMediaType AS VARIANT 'IN bstrMediaType AS STRING
    LOCAL vSortAttribute AS VARIANT 'IN bstrSortAttribute AS STRING
    LOCAL vBool AS VARIANT 'IN fSortAscending AS LONG
    '================================================================================
    LOCAL vPlaylist AS VARIANT
    '================================================================================

    OBJECT CALL oWMPlayer.mediaCollection.createQuery() TO vQuery

    vAttribute = "Title"
    vOperator = "Contains"
    vValue = "Blues"

    OBJECT CALL oWMPlayer.mediaCollection.createQuery().addCondition(vAttribute, vOperator, vValue)

    vQuery = ??? (POINTER to Query object)
    vMediaType = "Title"
    vSortAttribute = ""
    vBool = %FALSE

    OBJECT CALL oWMPlayer.mediaCollection.getPlaylistByQuery(vQuery, vMediaType, vSortAttribute, vBool) TO vPlaylist

    OBJECT LET oWMPlayer.currentPlaylist = vPlayList
Working...
X