my apps song player and iTunes are conflicting

Ok this may seem confusing to bear with me. In my application there is a function in which you type a song hit enter and that song is played. It seems that if you play a song using iTunes and then use the song search and play in my app it conflicts. Even though you played a song using my app the song you played in iTunes stays as the selection. So what happens is if you pause the song you played using my app and unpause it, it goes to the start of the song you played using iTunes and plays it…hopefully someone understands it:P

I will post some code that i think is causing the problem.

Song search and play method

on titlesearch()
	set songTitle to content of text field "title_search" of tab view item "search_tab" of tab view "my_tab" of window "mainWindow"
	repeat
		tell application "iTunes"
			set fixedIndexing to fixed indexing
			set fixed indexing to true
			
			set tracksFound to every track of first library playlist whose name contains songTitle
			set foundCount to count of tracksFound
			
			if foundCount is 1 then
				set playTrack to beginning of tracksFound
				exit repeat
			else if foundCount is not 0 then -- greater than 1    
				set tracksList to {}
				repeat with thisTrack in tracksFound
					set trackName to name of thisTrack
					tell artist of thisTrack to if it is "" then
						set trackArtist to "Unknown"
					else
						set trackArtist to it
					end if
					tell album of thisTrack to if it is "" then
						set trackAlbum to "Unknown"
					else
						set trackAlbum to it
					end if
					set trackInfo to trackName & " - " & trackArtist & " (" & trackAlbum & ")" as string
					set tracksList to tracksList & trackInfo
				end repeat
				
				set trackChosen to choose from list tracksList with prompt ¬
					"Your search turned up " & foundCount & " results. Please specify which track you want to play."
				if trackChosen is false then
					set fixed indexing to fixedIndexing
					return
				end if
				set my text item delimiters to return
				set tracksList to tracksList as Unicode text
				set my text item delimiters to beginning of trackChosen
				set trackNumber to count of paragraphs of first text item of tracksList
				set my text item delimiters to ""
				
				set playTrack to item trackNumber of tracksFound
				exit repeat
			end if
		end tell
		set songTitle to text returned of (display dialog "Your search turned up 0 results. Try again?." default answer "" buttons {"Cancel", "Go"} default button 2)
	end repeat
	tell application "iTunes"
		play playTrack
		set fixed indexing to fixedIndexing
		tell application "Finder" to set the visible of every process whose name is "iTunes" to false
	end tell
end titlesearch

on action handler for the method

on action theObject
	if the name of theObject is equal to "vol_control" then
		set enabled of slider of window "mainWindow" to true
		set volumevalue to integer value of theObject
		using terms from application "iTunes"
			tell application "iTunes"
				set the sound volume to volumevalue
			end tell
		end using terms from
	else if the name of theObject is equal to "title_search" then
		titlesearch()
	else if the name of theObject is equal to "artist_search" then
		artistsearch()
	end if
end action

anyone?
Since I posted this I have tried a lot of different things and it’s just not working…this is the only bug left in my program and I really need it fixed:cool:

Jaques, sorry I haven’t got back to you. I am on the students athletic council at school and have been busy for our local Fall Fair. It works like a charm! Thanks so much! You rule!:cool: