Difference between revisions of "ISDBApplicationEvents::OnDeviceFileCopied"

From MediaMonkey Wiki
Jump to: navigation, search
(Created page with "{{MethodDeclaration|SDBApplication|ISDBApplicationEvents|Sub OnDeviceFileCopied(Source as String, Destination as String, Success as Boolean)}} ===Parameters=== {{MethodParamete...")
(No difference)

Revision as of 12:54, 31 March 2014

CoClass SDBApplication, Interface ISDBApplicationEvents

Sub OnDeviceFileCopied(Source as String, Destination as String, Success as Boolean)


Parameters

Name Type Description
Source String Source path on PC
Destination String Path on device
Success Boolean Copy was successful (true), failed (false)


Event description

Is called whenever a file copy to device finishes.

Introduced in MediaMonkey version 4.1.1.


Example code

Option Explicit
 
Dim UI  : Set UI = SDB.UI
 
Sub OnStartUp()
    Dim mnuTest
    Set mnuTest = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
    mnuTest.Caption = SDB.Localize("Copy file to iPhone")
    mnuTest.OnClickFunc = "SDBOnClick"
    mnuTest.UseScript = Script.ScriptPath
    Script.RegisterEvent SDB, "OnDeviceFileCopied", "SDBDeviceFileCopied"    
End Sub
   
Dim DeviceHandle : DeviceHandle = -1   
   
Sub SDBOnClick(Item)     
  Dim Devices : Set Devices = SDB.Device.ActiveDeviceList("VID_05AC&PID_129E")
  Dim i : i = 0 
  For i = 0 To Devices.Count-1
	   If Devices.DeviceHandle(i) <> -1 Then
		   DeviceHandle = Devices.DeviceHandle(i)
	   End If
  Next
  
  SDB.Device.CopyFile DeviceHandle, "C:\Temp\MyFile.wmv", "/Temp/MyFile.wmv"
End Sub

Sub SDBDeviceFileCopied( DeviceHandle, Src, Dest, Success)
    if Success then
      MsgBox("File copied successfuly from "&Src&" to "&Dest)
    else
      MsgBox("File failed to copy from "&Src&" to "&Dest)
    end if  
    
    Dim Files
    Set Files = SDB.NewStringList 
    Files.Add "/Temp/MyFile.wmv"
    SDB.Device.DeleteFiles DeviceHandle, Files
  
End Sub