Browse Source

播放声音改成用wav就可以了

zhangyang 6 years ago
parent
commit
d9411306f5

BIN
bin/Win32/Debug/zhipuzi_pos_windows/db/pos.db


BIN
bin/Win32/Debug/zhipuzi_pos_windows/music/new_wamai_order.mp3


BIN
bin/Win32/Debug/zhipuzi_pos_windows/music/new_wamai_order.wav


+ 1 - 20
bin/Win32/Debug/zhipuzi_pos_windows/skin/main.xml

@@ -74,25 +74,6 @@
 					<Label text="还没开联系我们" />
 				</HorizontalLayout>
 			</TabLayout>
-        </VerticalLayout>
-        
-    	<VerticalLayout name="fadeEffect" visible="false" bkcolor="#20000000">
-    	    <Control />
-    	    <HorizontalLayout height="80" inset="0,10,0,0" >
-    	        <Control />
-    	        <VerticalLayout width="180" inset="6,6,6,6" bkimage="file='winbk.bmp' corner='4,48,4,4' mask='#FFFF00FF'">
-    	            <Label text="请选择你的操作" height="24" />
-    	            <HorizontalLayout inset="0,10,0,0" >
-    	                <Control />
-    	                <Button name="quitbtn" width="60" text="退出游戏" textcolor="#FFFF0000"/>
-				        <Control width="10"/>
-    	                <Button name="returnhallbtn" width="60" text="返回大厅" textcolor="#FFFF0000"/>
-    	                <Control />
-    	            </HorizontalLayout>
-    	        </VerticalLayout>
-    	        <Control />
-    	    </HorizontalLayout>
-    	    <Control />
-    	</VerticalLayout>    	        
+        </VerticalLayout>        
     </Container>
 </Window>

BIN
bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe


+ 12 - 0
lewaimai_dispatch/helper/CSystem.h

@@ -10,5 +10,17 @@ public:
 
 	//程序休眠X秒
 	static void my_sleep(int second);
+
+	static std::wstring GetProgramDir()
+	{
+		wchar_t exeFullPath[MAX_PATH]; // Full path
+		std::wstring strPath = L"";
+
+		GetModuleFileName(NULL, exeFullPath, MAX_PATH);
+		strPath = (wstring)exeFullPath;    // Get full path of the file
+
+		int pos = strPath.find_last_of('\\', strPath.length());
+		return strPath.substr(0, pos);  // Return the directory without the file name
+	}
 };
 

+ 4 - 12
lewaimai_dispatch/network/CMessagePush.cpp

@@ -102,16 +102,8 @@ void CMessagePush::HandleMessage(std::string msg)
 			//新订单来了,首先判断是否要语音提醒
 			if (CSetting::GetParam("setting_is_new_waimai_voice") == "1")
 			{
-				//需要语音提醒
-				std::wstring filepath = L"music/new_wamai_order.mp3";
-				std::wstring Open = L"OPEN " + filepath + L" ALIAS MUSIC";
-				mciSendString(Open.c_str(), NULL, 0, 0);
-
-				std::wstring Play = L"PLAY MUSIC FROM 0";
-				mciSendString(Play.c_str(), NULL, 0, 0);
-
-				std::wstring Close = L"CLOSE MUSIC";
-				mciSendString(Close.c_str(), NULL, 0, 0);
+				wstring path = CSystem::GetProgramDir() + L"\\music\\new_wamai_order.wav";
+				PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
 			}
 
 			//判断是否要自动确认
@@ -173,7 +165,7 @@ void CMessagePush::handle_read(const boost::system::error_code& error,
 	}
 	else
 	{
-		delete this;
+		//这里有时会出现,看看是什么错误,可能是断开了跟服务器的连接
 	}
 }
 
@@ -185,6 +177,6 @@ void CMessagePush::handle_write(const boost::system::error_code& error)
 	}
 	else
 	{
-		delete this;
+		//这里有时会出现,看看是什么错误,可能是断开了跟服务器的连接
 	}
 }