Jump to content

Media Player Embedding


MattyD
 Share

Recommended Posts

@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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 5 months later...

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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