Adds Music Search functionality to Windows and Mac. Provides the functionality of the Google Music Search and Google Open Storage Search Chrome add-ons to Windows and Mac users. Opens up the Google search query in the default system browser whatever that may be.
application.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?> <application xmlns="http://ns.adobe.com/air/application/1.5"> <id>com.timothytocci.example.Google.Music.Search</id> <filename>Google.Music.Search</filename> <name>Google.Music.Search</name> <version>1.0</version> <description/> <copyright/> <initialWindow> <content>Google.Music.Search.html</content> <systemChrome>none</systemChrome> <transparent>true</transparent> <resizable>false</resizable> </initialWindow> <icon> <image16x16>icons/musicsearch_16.png</image16x16> <image32x32>icons/musicsearch_32.png</image32x32> <image48x48>icons/musicsearch_48.png</image48x48> <image128x128>icons/musicsearch_128.png</image128x128> </icon> </application>
Google.Music.Search.html
<html> <head> <script type="text/javascript" src="lib/air/AIRAliases.js"> </script> <script type="text/javascript"> var thisVersion, currentVersion; var iconLoadComplete = function(event){ air.NativeApplication.nativeApplication.icon.bitmaps = [event.target.content.bitmapData]; } air.NativeApplication.nativeApplication.autoExit = false; var iconLoad = new air.Loader(); var iconMenu = new air.NativeMenu(); var showSearchCommand = iconMenu.addItem(new air.NativeMenuItem("Music Search")); showSearchCommand.addEventListener(air.Event.SELECT, function(event){ showSearch(); }); var exitCommand = iconMenu.addItem(new air.NativeMenuItem("Exit")); exitCommand.addEventListener(air.Event.SELECT, function(event){ air.NativeApplication.nativeApplication.icon.bitmaps = []; air.NativeApplication.nativeApplication.exit(); }); if (air.NativeApplication.supportsSystemTrayIcon) { air.NativeApplication.nativeApplication.autoExit = false; iconLoad.contentLoaderInfo.addEventListener(air.Event.COMPLETE, iconLoadComplete); iconLoad.load(new air.URLRequest("icons/musicsearch_16.png")); air.NativeApplication.nativeApplication.icon.tooltip = gettooltip(); air.NativeApplication.nativeApplication.icon.menu = iconMenu; } if (air.NativeApplication.supportsDockIcon) { iconLoad.contentLoaderInfo.addEventListener(air.Event.COMPLETE, iconLoadComplete); iconLoad.load(new air.URLRequest("icons/musicsearch_128.png")); air.NativeApplication.nativeApplication.icon.menu = iconMenu; } checkVersion(); showSearch(); function checkVersion(){ var appData = air.NativeApplication.nativeApplication.applicationDescriptor; var dp = new DOMParser(); var xml = dp.parseFromString(appData, "text/xml"); var version = xml.getElementsByTagName("version")[0].firstChild; thisVersion = version.nodeValue; var url = new air.URLRequest("http://weyou.us/apps/GoogleMusicSearch/version/"); var loader = new air.URLLoader(); loader.dataFormat = air.URLLoaderDataFormat.TEXT; loader.addEventListener(air.Event.COMPLETE, compareVersion); loader.load(url); } function compareVersion(e){ currentVersion = e.currentTarget.data; if (currentVersion > thisVersion) { openInBrowser("http://weyou.us/apps/GoogleMusicSearch/"); } } function gettooltip(){ var temp = ""; temp = "Google Music Search" + "\n"; temp = temp + " Use google to find music."; return temp; } function showSearch(){ var init = new air.NativeWindowInitOptions(); var win = null; var height = 228; var width = 500; // adobe bug - should be centered perfectly var top = (air.Capabilities.screenResolutionX / 2) - (height / 2); var left = (air.Capabilities.screenResolutionY / 2) - (width / 2); var spot = new air.Rectangle(top, left, width, height); init.minimizable = true; init.maximizable = true; init.resizable = false; init.type = "lightweight"; init.systemChrome = air.NativeWindowSystemChrome.NONE; win = air.HTMLLoader.createRootWindow(true, init, false, spot); var form = air.File.applicationDirectory.resolvePath("search.html"); win.load(new air.URLRequest(form.url)); } function openInBrowser(url){ air.navigateToURL(new air.URLRequest(url)); } </script> </head> <body> <!-- This page is never shown. --> </body> </html>
search.html
<html> <head> <style> body { background-color: white; } input { height: 30px; width: 450px; } #goo { padding-top: 20px; } </style> <script type="text/javascript" src="lib/air/AIRAliases.js"> </script> <script type="text/javascript"> var win = window.nativeWindow; var stay = false; var staycount = 0; function close(){ win.close(); } function timeout(){ if (!stay) { close(); } else { staycount++; } if (staycount === 3) { staycount = 0; stay = false; } } function doquery(query){ url = "https://www.google.com/search?q=" + encodeURIComponent(query); openInBrowser(url); } function openInBrowser(url){ air.navigateToURL(new air.URLRequest(url)); } window.onload = function(){ var dlg = document.getElementsByTagName("body"); dlg[0].addEventListener("mousedown", function(){ stay = true; staycount = 0; win.startMove(); }, false); dlg[0].addEventListener("mouseover", function(){ stay = true; staycount = 0; }, false); var inpt = document.getElementById("query"); inpt.addEventListener("change", function(){ stay = true; staycount = 0; }, false); var btnmusic = document.getElementById("music"); btnmusic.addEventListener("click", function(){ var input = document.getElementById("query"); var text = input.value; var query = 'intitle:index.of +?last modified? +?parent directory? +(mp3|wma|ogg|wav) +"' + text + '" -htm -html -php -asp -jsp -"Passwords"'; doquery(query); win.close(); }, false); var btnstorage = document.getElementById("storage"); btnstorage.addEventListener("click", function(){ var input = document.getElementById("query"); var temp = input.value.split(" ", 2); var filetype = temp[0]; text = temp[1]; var query = 'intitle:index.of +?last modified? +?parent directory? +(' + filetype + ') +"' + text + '" -htm -html -php -asp -jsp -"Passwords"'; doquery(query); win.close(); }, false); setInterval(timeout, 5000); } </script> </head> <body> <center> <div id="goo"> <img src="google_logo_front.png"/> </div> <br/> <div> <input name="query" id="query" type="text" align="center" placeholder="enter a bandname or filetype and query"/> <br/> <button id="music"> <img src="google_music_search_button.png"/> </button> <button id="storage"> <img src="google_open_storage_search_button.png"/> </button> </div> </center> </body> </html>
Original Source
MD5: ff8765b516c027539d18693a8b0adc73
Install Music Search
MD5: d3084dfb2406a68a3957d63acffa33c1
Adobe AIR application installers can be unzipped to inspect the code (if you don’t have 7-Zip you’ll have to change the file extension to .zip – do it on a copy).