Sign in to follow this  
Followers 0
careca

sound player doesn't work

3 posts in this topic

Hey ppl, working on a sound player...yea another. Seen some examples but nothing helped me, this sometimes worked, others didn't, and now it just doesn't...

There was a problem recently in retrieving the file paths, solved, worked a bit more on it, stopped working, and don't see any reason why.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Resources\anim-play.ico
#AutoIt3Wrapper_Res_Icon_Add=Resources\anim-play.ico
;#AutoIt3Wrapper_Run_Tidy=y
;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <Sound.au3>
#include <WinAPI.au3>
#include <GuiEdit.au3>
#include <GuiButton.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <GuiImageList.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <RecFileListToArray.au3>
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 1)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 0)
Opt("GUIEventOptions", 1)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
TraySetIcon("Resources\anim-stop.ico")
Local $GUI, $Frm_Main, $Read, $File, $ToTray, $Restore, $ExitItem, $Clear
Local $Input_1, $Input_2, $Button_1, $Button_2, $Button_3, $Button_4, $Button_5, $Box1
Local $Opened_File, $Play, $cListView, $ListClick, $ListStr, $InputCk, $iMsgBoxAnswer
Local $aList, $array, $array1, $array2, $array3, $array4, $arrayL, $arrayR

$GUI = GUICreate("Beats", 500, 500, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Restore")
$cListView = GUICtrlCreateListView("Path|File", 8, 64, 485, 300)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 380)
$Input_1 = GUICtrlCreateInput("Root Folder", 10, 10, 480, 20)
$Input_2 = GUICtrlCreateInput("Filename", 10, 40, 480, 20)
$Button_1 = GUICtrlCreateButton("File...", 270, 385, 60, 20)
GUICtrlSetOnEvent($Button_1, "OpenFile")
$Button_1 = GUICtrlCreateButton("Folder...", 340, 385, 60, 20)
GUICtrlSetOnEvent($Button_1, "OpenFolder")
$Button_2 = GUICtrlCreateButton("Play", 10, 385, 80)
GUICtrlSetOnEvent($Button_2, "Play")
$Button_3 = GUICtrlCreateButton("Pause", 95, 385, 80)
GUICtrlSetOnEvent($Button_3, "Pause")
$Button_4 = GUICtrlCreateButton("Stop", 180, 385, 80)
GUICtrlSetOnEvent($Button_4, "Stop")
$Button_5 = GUICtrlCreateButton("Clear", 180, 465, 80)
GUICtrlSetOnEvent($Button_5, "Clear")
$Box1 = GUICtrlCreateCheckbox("Clear List on file import", 10, 440, 120, 20)

GUISetState()
TraySetState(1)
TraySetClick(16)

$ToTray = TrayCreateItem("Tray")
TrayItemSetOnEvent(-1, "ToTray")
$Restore = TrayCreateItem("Restore")
TrayItemSetOnEvent(-1, "TRestore")
$ExitItem = TrayCreateItem("Close")
TrayItemSetOnEvent(-1, "Quit")

;MsgBox (64, '', )

;=============================================================================

;Functions

Func OpenFile()
If $Play = 1 Then
$iMsgBoxAnswer = MsgBox(8241,"Warning","The player is playing a file, if you continue, the playback will stop, do you want to continue?")
Select
Case $iMsgBoxAnswer = 1 ;OK
TraySetIcon('Resources\anim-stop.ico')
_SoundStop($File)
$Play = 0
$Clear = GUICtrlRead($Box1)
If $Clear = $GUI_CHECKED Then
_GUICtrlListView_DeleteAllItems($cListView)
EndIf
OpenFile2()
Case $iMsgBoxAnswer = 2 ;Cancel
EndSelect ;SELECT
Else
OpenFile2()
EndIf
EndFunc ;==>Open

Func OpenFile2()
$Clear = GUICtrlRead($Box1)
If $Clear = $GUI_CHECKED Then
_GUICtrlListView_DeleteAllItems($cListView)
EndIf
$Opened_File = FileOpenDialog("Open Music File", "", "All Music Files (*.wav;*.avi;*.mp3)|All Files (*.*)", 3)
$array4 = StringLen($Opened_File)
$array3 = StringInStr($Opened_File, "\", 0, -1)
$array2 = $array4 - $array3
$arrayL = StringTrimRight($Opened_File, $array2)
$arrayR = StringTrimLeft($Opened_File, $array3)
GUICtrlSetData($Input_1, $arrayL)
GUICtrlSetData($Input_2, $arrayR)
GUICtrlCreateListViewItem($arrayL & '|' & $arrayR, $cListView)
EndFunc

Func OpenFolder()
If $Play = 1 Then
$iMsgBoxAnswer = MsgBox(8241,"Warning","The player is playing a file, if you continue, the playback will stop, do you want to continue?")
Select
Case $iMsgBoxAnswer = 1 ;OK
TraySetIcon('Resources\anim-stop.ico')
_SoundStop($File)
$Play = 0
$Clear = GUICtrlRead($Box1)
If $Clear = 1 Then
_GUICtrlListView_DeleteAllItems($cListView)
EndIf
Case $iMsgBoxAnswer = 2 ;Cancel
EndSelect ;SELECT
Else
OpenFolder2()
EndIf
EndFunc ;==>Open

Func OpenFolder2()
$Clear = GUICtrlRead($Box1)
If $Clear = 1 Then
_GUICtrlListView_DeleteAllItems($cListView)
EndIf
$Opened_File = FileSelectFolder("Open Music File", "R:\", 2)
$array4 = StringLen($Opened_File)
$array3 = StringInStr($Opened_File, "\", 0, -1)
$array2 = $array4 - $array3
$arrayL = StringTrimRight($Opened_File, $array2)
$arrayR = StringTrimLeft($Opened_File, $array3)
GUICtrlSetData($Input_1, $arrayL)
GUICtrlSetData($Input_2, $arrayR)
$aList = _RecFileListToArray($arrayL, "*.mp3;*.wav;*.wma", 1, 1, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
$array4 = StringLen($aList[$u])
$array3 = StringInStr($aList[$u], "\", 0, -1)
$array2 = $array4 - $array3
$arrayL = StringTrimRight($aList[$u], $array2)
$arrayR = StringTrimLeft($aList[$u], $array3)
GUICtrlSetData($Input_1, $arrayL)
GUICtrlSetData($Input_2, $arrayR)
GUICtrlCreateListViewItem($arrayL & '|' & $arrayR, $cListView)
Next
EndIf
EndFunc ;==>Open

Func Play()
If $Play = 1 Then
_SoundStop($File)
EndIf
TraySetIcon('Resources\anim-play.ico')
$File1 = GUICtrlRead($Input_1)
$File2 = GUICtrlRead($Input_2)
$File = $File1&$File2
$ListClick = GUICtrlRead($cListView)
If $ListClick = 0 Then
MsgBox (64, '0', $File)
$Play = _SoundPlay($File)
$Play = 1
Else
$ListStr = GUICtrlRead($ListClick)
$File = StringReplace($ListStr, '|', '')
$array4 = StringLen($File)
$array3 = StringInStr($File, "\", 0, -1)
$array2 = $array4 - $array3
$arrayL = StringTrimRight($File, $array2)
$arrayR = StringTrimLeft($File, $array3)
GUICtrlSetData($Input_1, $arrayL)
GUICtrlSetData($Input_2, $arrayR)
$File1 = GUICtrlRead($Input_1)
$File2 = GUICtrlRead($Input_2)
$File = $File1&$File2
MsgBox (64, 'not 0', $File)
$Play = _SoundPlay($File)
$Play = 1
EndIf
TrayTip('', 'Playing: ' & $File, '', 1)
EndFunc ;==>Play

Func Pause()
$Play = 0
TraySetIcon('Resources\anim-stop.ico')
_SoundPause($File)
TrayTip('', 'Paused!','', 1)
EndFunc ;==>Pause

Func Stop()
$Play = 0
TraySetIcon('Resources\anim-stop.ico')
_SoundStop($File)
TrayTip('', 'Stopped!', '', 1)
EndFunc ;==>Stop

Func Clear()
_GUICtrlListView_DeleteAllItems($cListView)
EndFunc

;=============================================================================

;Window Actions

Func Minimize()
WinSetState('', '', @SW_MINIMIZE)
EndFunc ;==>Minimize

Func Restore()
WinSetState('', '', @SW_RESTORE)
EndFunc ;==>Restore


Func ToTray()
TrayItemSetState($ToTray, $TRAY_UNCHECKED)
GUISetState(@SW_HIDE)
EndFunc ;==>ToTray

Func TRestore()
TrayItemSetState($Restore, $TRAY_UNCHECKED)
GUISetState(@SW_SHOW)
EndFunc ;==>TRestore

Func Quit()
Exit
EndFunc ;==>Quit

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;=============================================================================

PS: Forum eats the includes...before i post.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites



The words "doesn't work" should be banished from everyone's vocabulary unless followed by AN EXPLANATION OF WHAT "doesn't work".


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

File wasn't reproducing, added "_SoundOpen($File)" And now it seems to be working, i mean it plays back now, it's weird because an hour ago, it worked without this piece of code.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


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
Sign in to follow this  
Followers 0