Jump to content

Subscript used on non-accessible variable for _Soundlenght


Recommended Posts

Okay like this is the error :

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Boro\Desktop\Skolaaa.au3"    
"C:\Program Files (x86)\AutoIt3\Include\Sound.au3" (261) : ==> Subscript used on non-accessible variable.:
__SoundMciSendString("set " & $aSndID[0] & " time format milliseconds")
__SoundMciSendString("set " & $aSndID^ ERROR
>Exit code: 1    Time: 114


If i use wav or wma files it works perfectly,but if i use mp3 files it gives this error.Any help?

#include <Array.au3>
#include <File.au3>
#include <Sound.au3>
#include<MsgBoxConstants.au3>


Global $aFiles = _FileListToArrayRec("C:\Users\Boro\Desktop\dadada","*.mp3",$FLTAR_FILES, $FLTAR_RECUR)
Global $iPos=1
Global $Broj=1
 $Pjesma=_SoundOpen("C:\Users\Boro\Desktop\dadada" & "\" & $aFiles[$Broj])

Func Pusti()
   _ArrayShuffle($aFiles)
 $Pjesma=_SoundOpen("C:\Users\Boro\Desktop\dadada" & "\" & $aFiles[$Broj])
 _SoundPlay($Pjesma)
 _SoundLength("C:\Users\Boro\Desktop\dadada" & "\" & $aFiles[$iPos],1)

 Sleep(1000)
If _SoundStatus($Pjesma)="0" Then
   _ArrayShuffle($aFiles)
   Pusti()
   EndIf
 EndFunc
Func KrajCasa ()

 Soundplay("C:\Users\Boro\Desktop\New\123.wav",0)
Sleep(10000)
Soundplay("")
_ArrayShuffle($aFiles)
Pusti()


   EndFunc
Func PocetakCasa()
   _SoundStop($Pjesma)
   Soundplay("")
    Soundplay("C:\Users\Boro\Desktop\New\123.wav",0)
Sleep(10000)
Soundplay("")
EndFunc

Func VelikiOdmor()
   Soundplay("C:\Users\Boro\Desktop\New\123.wav",0)
   Sleep(10000)
   Soundplay("")
_ArrayShuffle($aFiles)
Pusti()
While @Hour=9 And @Min<20
If _SoundPos($Pjesma)=_SoundLength($Pjesma) Then
   Sleep(5000)
   Pusti()
EndIf
If _SoundStatus($Pjesma)="0" Then
   SoundPlay("")
   _ArrayShuffle($aFiles)
   Call("Pusti")

EndIf
WEnd
EndFunc
Func MaliOdmor()
   Soundplay("C:\Users\Boro\Desktop\New\123.wav",0)
   Sleep(10000)
   Soundplay("")
_ArrayShuffle($aFiles)
Pusti()
While @Hour<=11 And @Min<5
If _SoundPos($Pjesma)=_SoundLength($Pjesma) Then
   Sleep(5000)
   Pusti()
EndIf
If _SoundStatus($Pjesma)="0" Then
   SoundPlay("")
   _ArrayShuffle($aFiles)
   Call("Pusti")

EndIf
WEnd
EndFunc

While 1
   If @Hour=7 And @MIN=30 And @Sec=0 Then PocetakCasa()
      If @Hour=8 And @Min=15 And @Sec=0  Then KrajCasa()
         If @Hour=8 And @Min=20 And @Sec=0  Then PocetakCasa()
            If @Hour=9 And @Min=5 And @Sec=0  Then VelikiOdmor()
               If @Hour=9 And @Min=20 And @SEC=5 Then PocetakCasa()
                  If @Hour=10 And @Min=5 And @Sec=0  Then KrajCasa()
                     If @Hour=10 And @Min=10 And @Sec=0  Then PocetakCasa()
                        IF @Hour=10 And @Min=55 And @Sec=0  Then MaliOdmor()
                           If @Hour=11 And @Min-5 And @Sec=5 Then PocetakCasa()
                              If @Hour=11 And @Min=50 And @Sec=0  Then KrajCasa()
                                 If @Hour=11 And @Min=55 And @Sec=0  Then PocetakCasa()
                                    If @Hour=12 And @Min=40 And @Sec=0  Then KrajCasa()
                                       If @Hour=12 And @Min=45 And @Sec=0  Then PocetakCasa()
                                          If @Hour=13 And @Min=30 And @Sec=0  Then KrajCasa()

                                          If @Hour=14 And @Min=0 And @Sec=0  Then PocetakCasa()
      If @Hour = 14 And @Min=45 And @Sec=0  Then KrajCasa()
         If @Hour=14 And @Min=50 And @Sec=0  Then PocetakCasa()
            IF @Hour=15 And @Min=35 And @Sec=0  Then VelikiOdmor1()
               If @Hour=15 And @Min=50 And @SEC=5 Then PocetakCasa()
                  If @Hour=16 And @Min=35 And @Sec=0  Then KrajCasa()
                     If @Hour=16 And @Min=40 And @Sec=0  Then PocetakCasa()
                        If @Hour=17 And @Min=25 And @Sec=0  Then MaliOdmor()
                           If @Hour=17 And @Min=35 And @Sec=5 Then PocetakCasa()
                              If @Hour=18 And @Min=20 And @Sec=0  Then KrajCasa()
                                 if @Hour=18 And @Min=25 And @Sec=0  Then PocetakCasa()
                                    If @Hour=19 And @Min=10 And @Sec=0  Then KrajCasa()
                                       If @Hour=19 And @Min=15 And @Sec=0  Then PocetakCasa()
                                          If @Hour=20 And @Min=0 And @Sec=0  Then KrajCasa()
                                          WEnd




Func VelikiOdmor1()
   Soundplay("C:\Users\Boro\Desktop\New\123.wav",0)
   Sleep(10000)
   Soundplay("")
_ArrayShuffle($aFiles)
Pusti()
While @Hour=15 And @Min<50
If _SoundPos($Pjesma,1)=_SoundLength($Pjesma,1) Then
   Sleep(5000)
   Pusti()
EndIf
If _SoundStatus($Pjesma)="0" Then
   SoundPlay("")
   _ArrayShuffle($aFiles)
   Call("Pusti")

EndIf
WEnd
EndFunc

Func MaliOdmor1()
   Soundplay("C:\Users\Boro\Desktop\New\123.wav",0)
   Sleep(10000)
   Soundplay("")
_ArrayShuffle($aFiles)
Pusti()
While @Hour=17 And @Min<35
If _SoundPos($Pjesma)=_SoundLength($Pjesma) Then
   Sleep(5000)
   Pusti()
EndIf
If _SoundStatus($Pjesma)="0" Then
   SoundPlay("")
   _ArrayShuffle($aFiles)
   Call("Pusti")

EndIf
WEnd
EndFunc


 

Edited by Melba23
Added code tags
Link to post
Share on other sites
  • Moderators

Yazgul,

Your code makes no attempt ot find out if the _SoundOpen call was successful - if it was not then the returned $aSnd value will most likely not be an array and so the UDF will fail. Add some errorchecking after the _SoundOpen call and take appropriate action if the file does not open.

As to why it only happens with .mp3 files - I have often found that a corrupt ID2/3 tag can make the file fail to open, so you might want to check that the tags are correct on any file which displays this behaviour.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...