• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iTunes Playlist
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iTunes Playlist


  • Subject: Re: iTunes Playlist
  • From: Alastair Leith <email@hidden>
  • Date: Fri, 15 Jun 2018 18:50:48 +0800

Hi Takaaki

I’ve come back to this code you sent, the last line has a typo I think

bStr’s writeToFile:aTargLoc atomically:true encoding:(current application's
NSUTF8StringEncoding) |error|:(missing value)

All the other lines compile okay, but without this line I can’t run the code.

Thanks again
Alastair


> On 4 Jun 2018, at 6:49 pm, Takaaki Naganoya <email@hidden> wrote:
>
> Hm……?
>
> You wrote “a way to write the data somewhere I can get to it from QC”.
> Yes. AppleScript can write plist data somewhere you hope.
>
> Can QC read the plist data? Is there some limitation with reading plist file?
>
>
> <AppleScript>
>
> use AppleScript version "2.5" --macOS 10.11 or later
> use scripting additions
> use framework "Foundation"
>
> set nextTrack to "next track name"
> set curPlayList to "current playlist name"
>
> set aList to {nextTrackName:nextTrack, curPlayListName:curPlayList}
>
> set anArray to current application's NSArray's arrayWithObject:aList
> set pListData to current application's NSPropertyListSerialization's
> dataFromPropertyList:anArray |format|:(current application's
> NSPropertyListXMLFormat_v1_0) errorDescription:(missing value)
> set bStr to (current application's NSString's alloc()'s
> initWithData:pListData encoding:(current application's NSUTF8StringEncoding))
>
>
> set aTargLoc to POSIX path of (choose file name)
> bStr’s writeToFile:aTargLoc atomically:true encoding:(current application's
> NSUTF8StringEncoding) |error|:(missing value)
>
> </AppleScript>
>
> --
> Takaaki Naganoya
> email@hidden
> http://piyocast.com/as/
>
>
>
>> 2018/06/04 18:57、Alastair Leith <email@hidden>のメール:
>>
>> Thanks Takaaki
>>
>> I hadn’t noticed you email today and set about writing the code to get next
>> track. I’l have to take a look at your script tonight.
>>
>> It’s a bit wordy as I was learning as I went.
>>
>> All I need now is a way to write the data somewhere I can get to it from QC.
>> Like say a .plist file then use the Read File patch (Kineme File Tools).
>>
>> tell application "iTunes"
>>      --      set myPlaylist to view of front window -- selected playlist
>>      try
>>              set myPlaylist to current playlist -- selected playlist
>>      end try
>>      set myCount to 1
>>      repeat with aTrack in (get every track of myPlaylist)
>>              set msg to ((myCount & ": " & album of aTrack as text) & " | "
>> & artist of aTrack as text) & " | "
>>              set myCount to myCount + 1
>>              log msg
>>      end repeat
>>      log "Current Playlist is called: " & name of current playlist as text
>> -- (track, r/o) : the current targeted track
>>      log "Currently playing track is: " & name of current track as text
>>
>>      set nextTrack to {}
>>      set sumTracks to count tracks in current playlist
>>      repeat with n from 1 to (sumTracks - 1)
>>              if name of track n of myPlaylist = name of current track then
>>                      set nextTrack to track (n + 1) of myPlaylist
>>                      log ("Track " & n & " of playlist " & name of
>> myPlaylist & " matches the current track: " & name of current track)
>>              end if
>>              set myCount to myCount + 1
>>      end repeat
>>      if nextTrack ≠ {} then
>>              log "Next track to play is: " & name of nextTrack as text
>>      else if myPlaylist ≠ {} then
>>              log "There is currently no playlist being played"
>>      else
>>              log "No next track to play. (Last song in playlist).”  -- note
>> this line never gets run b/c myPlaylists is assigned to {} when the last
>> track is being played (an iTunes thing)
>>
>>      end if
>> end tell
>>
>>
>>> On 4 Jun 2018, at 8:41 am, Takaaki Naganoya <email@hidden> wrote:
>>>
>>> This is my QuartzComposer test script. It display and set values from
>>> AppleScript (requires Control-Command-R to run).
>>>
>>> http://piyocast.com/as/archives/2314
>>>
>>> Whole script (including QuartzCompozer document in its script bundle) is
>>> here.
>>>
>>> http://piyocast.com/as/wp-content/uploads/2018/02/QuartzComoser_as5.zip
>>>
>>> I hope this will help you.
>>>
>>>
>>>> 2018/06/03 1:27、Alastair Leith <email@hidden>のメール:
>>>>
>>>> I found the “current playlist” property for iTune in its dictionary. And I
>>>> found some basic scripts to get it’s value/object here.
>>>>
>>>> tell application "iTunes"
>>>>  set thePlaylist to current playlist
>>>> end tell
>>>>
>>>> Wanting to know which track is the next to play, after the current one. Is
>>>> track 1 current and track 2 next track?
>>>>
>>>> get name of track 1 of thePlaylist
>>>>
>>>> I need to write this someplace, maybe to a file maybe I can find a socket
>>>> or something to get it into some Quartz Composer software I’ve written.
>>>>
>>>> Thanks
>>>> Alastair
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> AppleScript-Users mailing list      (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>> Archives: http://lists.apple.com/archives/applescript-users
>>>>
>>>> This email sent to email@hidden
>>>
>>> --
>>> Takaaki Naganoya
>>> email@hidden
>>> http://piyocast.com/as/
>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> AppleScript-Users mailing list      (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>> Archives: http://lists.apple.com/archives/applescript-users
>>>
>>> This email sent to email@hidden
>>
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: iTunes Playlist
      • From: Shane Stanley <email@hidden>
References: 
 >iTunes Playlist (From: Alastair Leith <email@hidden>)
 >Re: iTunes Playlist (From: Takaaki Naganoya <email@hidden>)
 >Re: iTunes Playlist (From: Alastair Leith <email@hidden>)
 >Re: iTunes Playlist (From: Takaaki Naganoya <email@hidden>)

  • Prev by Date: Re: [ANN] FileManagerLib update
  • Next by Date: Re: iTunes Playlist
  • Previous by thread: Re: iTunes Playlist
  • Next by thread: Re: iTunes Playlist
  • Index(es):
    • Date
    • Thread