DeviceHandle does not work for all devices [#11993]

Beta Testing for Windows Products and plugins

Moderator: Gurus

ceinj
Posts: 65
Joined: Sun Mar 22, 2009 4:36 pm

DeviceHandle does not work for all devices [#11993]

Post by ceinj »

MM 4.1.0.1629 on XP and Windows 7. I have a vbs script that uses the new DeviceHandle call but it doesn't report many connected devices. I had an iPhone, HTC (Android) and a Thumbdrive connected to the computers. MM showed these devices in its tree but only the DeviceHandle for the iPhone returned a value other than -1.

Also calling the function/property takes a long time (just a precautionary warning to scripters).
Ludek
Posts: 4959
Joined: Fri Mar 09, 2007 9:00 am

Re: (Scripting) DeviceHandle does not work for all devices

Post by Ludek »

You seem to be right,
it works for my Android phone in MTP mode, for iPhone, but doesn't work for my USB stick (with assigned drive letter), I guess this is case for your devices?

I will fix it as http://www.ventismedia.com/mantis/view.php?id=10708
ceinj
Posts: 65
Joined: Sun Mar 22, 2009 4:36 pm

Re: (Scripting) DeviceHandle does not work for all devices

Post by ceinj »

Yea! The new version fixes the problem and seems to be much faster.

Thanks!
ceinj
Posts: 65
Joined: Sun Mar 22, 2009 4:36 pm

Re: (Scripting) DeviceHandle does not work for all devices

Post by ceinj »

New issue found. Running version 4.1.0.1664. I plug in an Android phone and two devices show up in MM (phone and SD card). I verified I can sync to both devices using MM manually. When I try writing a script it seems that there is only a single "DeviceHandle" for this device and there is no way to copy to the SD card.
Ludek
Posts: 4959
Joined: Fri Mar 09, 2007 9:00 am

Re: (Scripting) DeviceHandle does not work for all devices

Post by Ludek »

Hi, so if you use example code here http://www.mediamonkey.com/wiki/index.p ... viceHandle to enumerate them then only one device is in the list?
i.e. SD Card and Phone have same VID and PID, but if you use something like (with your device VID/PID)

Code: Select all

Dim Devices : Set Devices = SDB.Device.ActiveDeviceList("VID_04E8&PID_6860")
then

Code: Select all

Devices.Count = 2
, isn't it?
ceinj
Posts: 65
Joined: Sun Mar 22, 2009 4:36 pm

Re: (Scripting) DeviceHandle does not work for all devices

Post by ceinj »

Both examples seem the same! They both return a device count of 2 but only 1 has a valid DeviceHandle.
Ludek
Posts: 4959
Joined: Fri Mar 09, 2007 9:00 am

Re: (Scripting) DeviceHandle does not work for all devices

Post by Ludek »

Strange, I don't see a reason for it.

So both SDCard and Phone are returned in the list, but SDcard has DeviceHandle = -1 ?
Which phone model it is?
If you try to initiate playback of tracks on the device from MM interface (Media Tree -> SD card -> Music...), do they play?
ceinj
Posts: 65
Joined: Sun Mar 22, 2009 4:36 pm

Re: (Scripting) DeviceHandle does not work for all devices

Post by ceinj »

The phone is a Samsung Galaxy Victory 4G LTE. In MM I have been able to copy different selections to the phone and the SD card and verified playback.

To clear up any misstatements I may have made, I wrote a small script to dump the device handle and other device information. Code snippet and results are below.

Code: Select all

  Dim list : Set list = SDB.Device.ActiveDeviceList("VID_04E8&PID_6860")
  If list.Count = 0 Then
    Call SDB.MessageBox(SDB.Localize("No active devices. [1]"),mtError,Array(mbOk))
    Exit Sub
  End If
  
  Dim inds : inds = ""
  Dim nams : nams = ""
  Dim boo : boo = False
  Dim txt
  Dim i : i = 0
  For i = 0 To list.Count-1 
    txt = ">>Dev " & i & " ID [" & list.DeviceID(i) & "] Device Count = " & list.Count & " Handle [" & list.DeviceHandle(i) & "]"
    Call fout.WriteLine(txt)
    If list.DeviceHandle(i) > -1 Then
      Dim indx : indx = list.DeviceID(i)
      Dim sqls : sqls = "SELECT DeviceCaption,DetailedUSBID FROM Devices WHERE DetailedUSBID LIKE '%"&indx&"%'"
      Dim iter : Set iter = SDB.Database.OpenSQL(sqls)
      While Not iter.EOF  
        txt = "  Detail Caption [" & iter.StringByIndex(0) & "]"
        Call fout.WriteLine(txt)
        txt = "  USB ID [" & iter.StringByIndex(1) & "]"
        Call fout.WriteLine(txt)
        iter.Next
      Wend
      Set iter = Nothing
    End If
  Next 
  Call fout.Close()
========== Results Below =============

>>Dev 0 ID [USB\VID_04E8&PID_6860\5014B028] Device Count = 1 Handle [49863440]
Detail Caption [SPH-L300 - Phone]
USB ID [Orig:USB\VID_04E8&PID_6860\5014B028
Found:USB\VID_04E8&PID_6860\5014B028
]
Detail Caption [SPH-L300 - Card]
USB ID [Orig:USB\VID_04E8&PID_6860\5014B028
Found:USB\VID_04E8&PID_6860\5014B028
]
Ludek
Posts: 4959
Joined: Fri Mar 09, 2007 9:00 am

Re: (Scripting) DeviceHandle does not work for all devices

Post by Ludek »

OK, so the issue is that the (Device Count = 1), I should have similar phone for testing next week so I am going to see If I can replicate.
Peke
Posts: 17493
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: (Scripting) DeviceHandle does not work for all devices

Post by Peke »

This should be better handled in 4.1.10.1765
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Post Reply