Jump to content

Recommended Posts

Posted (edited)

@MattyD excellent script, if Media Player could change the tune of the song I would even use it in my karaoke project.

Edited by Belini
Posted

Here my take on your great find.  Hope you don't mind.  Thanks again.

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", True)

Example()

Func Example()
  Local $oPlayer = ObjCreate("WMPlayer.OCX")
  GUICreate("Embedded Web control Test", 600, 200)
  GUICtrlCreateObj($oPlayer, 0, 0, 400, 100)
  $oPlayer.Settings.Volume = 100
  $oPlayer.uiMode = "none"
  $oPlayer.stretchToFit = True

  Local $sFullPath = "C:\Applications\AutoIt\WASApi\Don Henley - The Boys of Summer.mp3"

  $oPlayer.URL = $sFullPath
  While $oPlayer.playState = 9
    Sleep(50)
  WEnd
  If $oPlayer.playState <> 3 Then Exit MsgBox($MB_SYSTEMMODAL, "Error", $sFullPath & " cannot be played")
  ResizeOCX($oPlayer, 0, 0, 400, 100)
  GUISetState()

  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
    If $oPlayer.playState <> 3 Then ExitLoop
  WEnd
EndFunc   ;==>Example

Func ResizeOCX($oObject, $iLeft, $iTop, $iRight, $iBottom)
  Local Const $tagIOleInPlaceObj = _
      "ContextSensitiveHelp none(int); " & _
      "GetWindow none(ptr); " & _
      "InPlaceDeactivate none(); " & _
      "ReactivateAndUndo none(); " & _
      "SetObjectRects none(ptr; ptr;); " & _
      "UIDeactivate none();"
  Local Static $oIInPlace = ObjCreateInterface($oObject, "{00000113-0000-0000-C000-000000000046}", $tagIOleInPlaceObj)
  Local $tRect = DllStructCreate($tagRECT)
  $tRect.Left = $iLeft
  $tRect.Top = $iTop
  $tRect.Right = $iRight
  $tRect.Bottom = $iBottom
  Local $pRect = DllStructGetPtr($tRect)
  $oIInPlace.SetObjectRects($pRect, $pRect)
EndFunc   ;==>ResizeOCX

 

Posted

My pleasure, thanks all for the kind words.
And needless to say that's a good demo of yours Nine :)

hey CYCho - if we're talking 2030s, I'd bet WMP will get the axe at some point for an app from the MS Store.

Maybe we should be all looking at libvlc or something in the long term!

  • 5 months later...
Posted (edited)

Excellent UDF, I just couldn't incorporate a method to remove an item from the playlist, opposite of the _MP_PlaylistAdd($sPath) function... can any of your friends help?

Edited by mutleey
Posted

Maybe something like this (untested).

Func _MP_PlaylistRemoveItem($iIndex)
    ; https://docs.microsoft.com/de-de/windows/win32/wmp/wmplibiwmpplaylist-iwmpplaylist-removeitem--vb-and-c
    Local $oWMP = $aPlayerReg[$PREG_PLROBJ]
    Local $oPlaylist = $oWMP.CurrentPlaylist
    $oWMP.CurrentPlayList.RemoveItem($oPlaylist.Item($iIndex))
EndFunc   ;==>_MP_PlaylistRemoveItem

 

Posted

Thanks for the answer Kafu, I had tried something similar but I was not successful... I tested your code and it didn't delete either, I believe that when sending the parameters of the function I didn't send the right parameter.

Posted
13 hours ago, KaFu said:

Maybe something like this (untested).

Func _MP_PlaylistRemoveItem($iIndex)
    ; https://docs.microsoft.com/de-de/windows/win32/wmp/wmplibiwmpplaylist-iwmpplaylist-removeitem--vb-and-c
    Local $oWMP = $aPlayerReg[$PREG_PLROBJ]
    Local $oPlaylist = $oWMP.CurrentPlaylist
    $oWMP.CurrentPlayList.RemoveItem($oPlaylist.Item($iIndex))
EndFunc   ;==>_MP_PlaylistRemoveItem

This works for me.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...