Exemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
rho::String rho_log_path()
{
    if (!s_log_path.empty())
    {
        return s_log_path;
    }
    else
    {
        return s_root_path;
    }
}
Exemplo n.º 2
0
	// Play an audio file.
	virtual void start( const rho::String& filename, rho::apiGenerator::CMethodResult& oResult)
	{
		// Check that the filename is not empty or NULL.
		if (!filename.empty() && (!m_hPlayThread))
		{
			// Store the local filename away.
			//common::convertToStringW(filename, lFilename);
			lFilename = s2ws(filename);

			// Launch the audio player.
			playLocalAudio();
		}
	}
Exemplo n.º 3
0
	// Play an audio file.
	virtual void start( const rho::String& filename, rho::apiGenerator::CMethodResult& oResult)
	{
		// Check that the filename is not empty or NULL.
		if (!filename.empty() && (!m_hPlayThread))
		{
			// Download the audio file and store name in lFilename
			if(String_startsWith(filename, "http://") || String_startsWith(filename, "https://"))
			{
				rho::common::CRhoFile::deleteFile("download.wav");
				// Networked code
				LOG(INFO) + __FUNCTION__ + "Attempting to download the file. " + filename;
				NetRequest oNetRequest;
				Hashtable<String,String> mapHeaders;
				bool overwriteFile = true;
				bool createFolders = false;
				bool fileExists = false;
				String& newfilename = String("download.wav");

				// Call the download function with the url and new filename the temp filename to be used.
				net::CNetRequestHolder *requestHolder = new net::CNetRequestHolder();
				requestHolder->setSslVerifyPeer(false);
				NetResponse resp = getNetRequest(requestHolder).pullFile( filename, newfilename, NULL, &mapHeaders,overwriteFile,createFolders,&fileExists);

				delete requestHolder;

				if (!resp.isOK())
				{
					LOG(INFO) + __FUNCTION__ + " Could not download the file";
					return; // Don't attempt to play the file.
				}
				else
				{
					LOG(INFO) + __FUNCTION__ + " Could download the file";
					lFilename = s2ws(newfilename);
				}	
			}
			else
			{
				// Store the local filename away.
				lFilename = s2ws(filename);
			}

			// Launch the audio player.
			playLocalAudio();
		}
		
	}
Exemplo n.º 4
0
	// Start playing a video file.
    virtual void startvideo( const rho::String& filename, rho::apiGenerator::CMethodResult& oResult)
	{
		// Check that the filename is not empty or NULL.
		if (!filename.empty() &&  (!m_hPlayProcess))
		{
			PROCESS_INFORMATION pi;
			StringW m_lpzFilename = s2ws(filename);

			// Launch the video player.
			if (!CreateProcess(L"\\windows\\WMPlayer.exe", m_lpzFilename.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
			{
				// for WinCE CEPlayer we need to set a registry key to make sure it launches full screen
				HKEY hKey = 0;
				LPCWSTR subkey = L"SOFTWARE\\Microsoft\\CEPlayer";

				if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,subkey,0,0,&hKey) == ERROR_SUCCESS)
				{
					DWORD dwType = REG_DWORD;
					DWORD dwData = 1; // Set AlwaysFullSize to 1
					RegSetValueEx(hKey, L"AlwaysFullSize", 0, dwType, (BYTE*)&dwData, sizeof(dwData));
					RegCloseKey(hKey);
				}

				if (!CreateProcess(L"\\windows\\CEPlayer.exe", m_lpzFilename.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
				{
					// if CEPlayer doesn't exist either, try VPlayer
					if (!CreateProcess(L"\\windows\\VPlayer.exe", m_lpzFilename.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
					{
						LOG(INFO) + __FUNCTION__ +  "Error launching MediaPlayer";
						return;
					}
				}

				m_hPlayProcess = pi.hProcess;
				m_hPlayThread = pi.hThread;
			}
		}
	}
Exemplo n.º 5
0
	// Start playing a video file.
    virtual void startvideo( const rho::String& filename, rho::apiGenerator::CMethodResult& oResult)
	{
		// Attempt to kill the player.  If we don't do this, WMP holds a lock on the file and we cannot delete it.
		KillPlayer();
		rho::common::CRhoFile::deleteFile("download.wmv");

		// Check that the filename is not empty or NULL.
		if (!filename.empty() &&  (!m_hPlayProcess))
		{
			PROCESS_INFORMATION pi;
			StringW m_lpzFilename;

			if (String_startsWith(filename, "http://") || String_startsWith(filename, "https://"))
			{
				// Networked code
				LOG(INFO) + __FUNCTION__ + "Attempting to download the file. " + filename;
				NetRequest oNetRequest;
				Hashtable<String,String> mapHeaders;
				bool overwriteFile = true;
				bool createFolders = false;
				bool fileExists = false;
				String& newfilename = String("download.wmv");

				// Call the download function with the url and new filename the temp filename to be used.
				net::CNetRequestHolder *requestHolder = new net::CNetRequestHolder();
				requestHolder->setSslVerifyPeer(false);

				NetResponse resp = getNetRequest(requestHolder).pullFile( filename, newfilename, null, &mapHeaders,overwriteFile,createFolders,&fileExists);

				delete requestHolder;

				if (!resp.isOK())
				{
					LOG(INFO) + __FUNCTION__ + "Could not download the file";
					return; // Don't attempt to play the file.
				}
				else
				{
					LOG(INFO) + __FUNCTION__ + "Could download the file";
					m_lpzFilename = s2ws(newfilename);
				}
			}
			else
			{
				// Local file, just change the name to a format the WM/CE understands.
				m_lpzFilename = s2ws(filename);
			}

			// Launch the video player.
			if (!CreateProcess(L"\\windows\\WMPlayer.exe", m_lpzFilename.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
			{
				// for WinCE CEPlayer we need to set a registry key to make sure it launches full screen
				HKEY hKey = 0;
				LPCWSTR subkey = L"SOFTWARE\\Microsoft\\CEPlayer";

				if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,subkey,0,0,&hKey) == ERROR_SUCCESS)
				{
					DWORD dwType = REG_DWORD;
					DWORD dwData = 1; // Set AlwaysFullSize to 1
					RegSetValueEx(hKey, L"AlwaysFullSize", 0, dwType, (BYTE*)&dwData, sizeof(dwData));
					RegCloseKey(hKey);
				}

				if (!CreateProcess(L"\\windows\\CEPlayer.exe", m_lpzFilename.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
				{
					// if CEPlayer doesn't exist either, try VPlayer
					if (!CreateProcess(L"\\windows\\VPlayer.exe", m_lpzFilename.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
					{
						LOG(INFO) + __FUNCTION__ +  "Error launching MediaPlayer";
						return;
					}
				}

				m_hPlayProcess = pi.hProcess;
				m_hPlayThread = pi.hThread;
			}

			m_hPlayProcess = pi.hProcess;
			m_hPlayThread = pi.hThread;
		}
	}