Sub CreateMedia(Dir As String, FileName As String) As ResumableSub
Dim media As JavaObject
media.InitializeNewInstance("javafx.scene.media.Media", Array(File.GetUri(Dir, FileName)))
Dim player As JavaObject
player.InitializeNewInstance("javafx.scene.media.MediaPlayer", Array(media))
Dim millis As Double
For i = 1 To 20
Sleep(1000)
Dim state As String = player.RunMethod("getStatus", Null)
If state = "READY" Then
millis = media.RunMethodJO("getDuration", Null).RunMethod("toMillis", Null)
Exit
End If
Next
player.RunMethod("dispose", Null)
Return millis
End Sub