Page 1 of 1

Media Player ocx - nedd help

Posted: 20 Sep 2013 17:25
by Tonton Luc
Hi,

I add a new Com object from msdxm.ocx (Media Player) in my project and the following code works fine until the last line "play". I'm not sure if my approach is correct (?) :

Code: Select all

clauses     onFileNew(_Source, _MenuTag):-         mainexe::getFileName(Root,_),         Nom = "son.WMA",         Fic = fileName::setPath(Nom,Root),         if file::existFile(Fic) then             MP = mediaPlayer::new(),             MP:aboutBox(),             Ready = MP:get_ReadyState(),             stdio::write(Ready),stdio::nl,             MP:predicate_Open(Nom),             Ready3 = MP:get_ReadyState(),             stdio::write(Ready3),stdio::nl,             MP:set_CurrentPosition(5),             Pos = MP:get_CurrentPosition(),             stdio::write(Pos),stdio::nl,             MP:set_DisplayMode(mmm_typeRepository_MediaPlayer::mpTime),             MP:set_ShowDisplay(true),             F2 = MP:get_FileName(),             stdio::write(F2),stdio::nl,             ClickToPlay = MP:get_ClickToPlay(),             stdio::write(ClickToPlay),stdio::nl,             AutoStart = MP:get_AutoStart(),             stdio::write(AutoStart),stdio::nl,             MP:play() % !!! not ok         end if,         !.
========================================
Dump: 2013/09/20 19:17:14
----------------------------------------
Exception: unknownException (com/visual-prolog/com/exceptionHandling/exceptionHandling_exception)

Unknown exception

HRESULT code = 2148139013
HRESULT hex code = 800A0005
hresultDescription = Unknown exception
Predicate name = play

raised() 2013/09/20 19:17:08
ThreadId=228
ClassInfo: iMediaPlayer_import
Any :idea:

Posted: 21 Sep 2013 0:38
by Thomas Linder Puls
I have no experience with this. But I have seen that others uses windows\system32\wmp.dll.

Posted: 11 Nov 2014 14:00
by Tonton Luc
Hi,

I create a new COM object from wmp.dll and start to write the following code (VP 7.2) :

Code: Select all

constants     idc_wmp_ctl = 1000.   predicates     onShow : window::showListener. clauses     onShow(_Source, _Data):-         Rct = vpi::winGetClientRect(This:getVpiWindow()),         Rct = rct(Gauch,Haut,Droit,Bas),         New_rct = rct(Gauch, Haut,Droit,Bas-50),         Container = activeXContainer::new(This:getVpiWindow()),         Obj=Container:createControl(windowsMediaPlayer::componentClassID,New_rct,idc_wmp_ctl),         not(Obj=uncheckedConvert(iOleObject_native,null)),         !,         ?????         !.     onShow(_Source, _Data).
This part of code works fine and the player is displaying fine in my form, but how to play an MP3 file now ? I don't unsderstand which code do I use.
Any :idea:

Posted: 11 Nov 2014 21:52
by Tonton Luc
I've found the good code :

Code: Select all

        _Rep_Core = Obj:queryInterface(iWMPCore_native::iid,IUnk_Core),         Core = uncheckedConvert(iWMPCore_native,IUnk_Core),         _ = Core:set_url("C:\\My_file.MP3"),         _Rep = Obj:queryInterface(iWMPControls_native::iid,IUnk),         Ctl_controls = uncheckedConvert(iWMPControls_native,IUnk),         _ = Ctl_controls:play(),
:roll:

Posted: 28 Nov 2014 22:04
by Tonton Luc
Hi,

How to create a WMP PositionChange event ?
The following code generate an error :

Code: Select all

        _Rep_status = ctl_principal:queryInterface(iWMPEvents_native::iid,IUnk_events),         Cctl_events = uncheckedConvert(iWMPEvents_native,IUnk_events), %        Cctl_events:positionChange(Old,New),
error c603: The flow pattern '(o,o)' does not exist for 'iWMPEvents_native::positionChange/2'
In iWMPEvents_native.i :

Code: Select all

predicates     positionChange : (real OldPosition, real NewPosition)  language stdcall.
I would like to reproduce the WMP duration bar and I need to recover the CurrentPosition during a file is playing. So I supose I need to create a PositionChange event...

Posted: 1 Dec 2014 10:06
by Thomas Linder Puls
Events comes the other way, from the Active/X control to your program, so it is your program that should implement the iWMPEvents interface and then register it as a (so called) event sink.

To implement the iWMPEvents interface you can for example implement a class like this:

Code: Select all

class wmpEvents : iWMPEvents_native ... end class wmpEvents

Code: Select all

implement wmpEvents inherits iWMPEvents_export     supports iWMPEvents_impl   clauses     iWMPEvents_positionChange(OldPosition, NewPosition) :-         % This is called when the position changes ... end implement wmpEvents
Somewhere you should create aninstance of this class and pass it to some event listener registration function (like adviseWMPEvents).

Posted: 6 Dec 2014 21:44
by Tonton Luc
Hi,

I'm not sure to understand what I need to do (sorry).
So I've just created a new class named "wmpEvents" in my project :

Code: Select all

class wmpEvents : iWMPEvents_native     open core   predicates     classInfo : core::classInfo.     % @short Class information  predicate.     % @detail This predicate represents information predicate of this class.     % @end   end class wmpEvents
and a new wmpEvents.pro like :

Code: Select all

implement wmpEvents inherits iWMPEvents_export     supports iWMPEvents_impl     open core   constants     className = "TaskWindow/wmpEvents".     classVersion = "".   clauses     classInfo(className, classVersion).       iWMPEvents_positionChange(_OldPosition, _NewPosition) :- %        settext(toString(NewPosition)),         !.     iWMPEvents_openStateChange(_NewState).     iWMPEvents_playStateChange(_NewState).     iWMPEvents_audioLanguageChange(_LangID).     iWMPEvents_statusChange().     iWMPEvents_scriptCommand(_ScType, _Param).     iWMPEvents_newStream().     iWMPEvents_disconnect(_Result).     iWMPEvents_buffering(_Start).     iWMPEvents_error().     iWMPEvents_warning(_WarigType, _Param, _Descriptio).     iWMPEvents_endOfStream(_Result).     iWMPEvents_markerHit(_Markerum).     iWMPEvents_durationUnitChange(_NewDuratioUit).     iWMPEvents_cdromMediaChange(_Cdromum).     iWMPEvents_playlistChange(_Playlist, _Change).     iWMPEvents_currentPlaylistChange(_Change).     iWMPEvents_currentPlaylistItemAvailable(_BstrItemame).     iWMPEvents_mediaChange(_Item).     iWMPEvents_currentMediaItemAvailable(_BstrItemame).     iWMPEvents_currentItemChange(_PdispMedia).     iWMPEvents_mediaCollectionChange().     iWMPEvents_mediaCollectionAttributeStringAdded(_BstrAttribame, _BstrAttribVal).     iWMPEvents_mediaCollectionAttributeStringRemoved(_BstrAttribame, _BstrAttribVal).     iWMPEvents_mediaCollectionAttributeStringChanged(_BstrAttribame, _BstrOldAttribVal, _BstrewAttribVal).     iWMPEvents_playlistCollectionChange().     iWMPEvents_playlistCollectionPlaylistAdded(_BstrPlaylistame).     iWMPEvents_playlistCollectionPlaylistRemoved(_BstrPlaylistame).     iWMPEvents_playlistCollectionPlaylistSetAsDeleted(_BstrPlaylistame, _VarfIsDeleted).     iWMPEvents_modeChange(_Modeame, _NewValue).     iWMPEvents_mediaError(_PMediaObject).     iWMPEvents_openPlaylistSwitch(_PItem).     iWMPEvents_domainChange(_StrDomain).     iWMPEvents_switchedToPlayerApplication().     iWMPEvents_switchedToControl().     iWMPEvents_playerDockedStateChange().     iWMPEvents_playerReconnect().     iWMPEvents_click(_NButton, _NShiftState, _FX, _FY).     iWMPEvents_doubleClick(_NButton, _NShiftState, _FX, _FY).     iWMPEvents_keyDown(_NKeyCode, _NShiftState).     iWMPEvents_keyPress(_NKeyAscii).     iWMPEvents_keyUp(_NKeyCode, _NShiftState).     iWMPEvents_mouseDown(_NButton, _NShiftState, _FX, _FY).     iWMPEvents_mouseMove(_NButton, _NShiftState, _FX, _FY).     iWMPEvents_mouseUp(_NButton, _NShiftState, _FX, _FY).   end implement wmpEvents
and when I compile, I've this following error :
error c659: Inherited class 'iWMPEvents_export' is not initialized
:?: