私はAppleScript
をいくつかのアーティストのトップソングを再生できるようにしようとしています。私はScriptEditor
経由でiTunesのスクリプトライブラリを見たけど、私には役に立たないものは何も見つかりませんでした。このケースが可能な場合、誰かが正しい方向に私を転送することを願っています。ありがとう。AppleScriptのアーティストのTOP曲を再生
答えて
iTunesからトラックを取得する基本的な方法は、get every track
です。たとえば、
tell application "iTunes" to set topTracks to every track of playlist "Library" whose artist is "Golden Earring" and rating is 100
iTunes GUIでは1〜5星(または星印なし)ですが、バックエンドでは0〜100です。バックエンドの評価に20を掛けます(またはGUIのスター数についてはバックエンドの評価を20で割る)。0星は0に等しくなります。
iTunesには奇妙な点があります。 and rating is 100
を追加すると、簡単なもの(アーティスト)と難しいもの(レーティング)を行うのではなく、両方のクエリを検索してまとめているかのように、クエリが非常に遅くなります。そのため、これはおそらく、はるかに高速に特定のアーティストの五格のトラックのすべてを得ることで、非常に次のようになります。
tell application "iTunes"
set artistTracks to every track of playlist "Library" whose artist is "Golden Earring"
set topTracks to {}
repeat with possibleTrack in artistTracks
if the rating of possibleTrack is 100 then copy possibleTrack to end of topTracks
end repeat
end tell
、「トップソング」で、あなたはトップX曲を意味している場合xに達するのに十分なレーティング5のトラックがあるという保証はありませんので、特定の番のトラックをにするには、5トラックを取得し、十分なあなたがそれをする方法の一例がありますが、それはあなたが「トップソング」をどのように定義するかに部分的に依存します。
あなたは誰もGUIでトラックを一時停止していないか、進めることを合理的に確実な場合 topTracksリスト内の次のトラックに進みとき選択するためのtell application "iTunes"
set desiredArtist to "chi coltrane"
--get topCount tracks
set topCount to 5
set fiveStars to {}
set fourStars to {}
set threeStars to {}
set twoStars to {}
set oneStar to {}
set noStars to {}
set allTracks to every track of playlist "Library" whose artist is desiredArtist
--collect tracks into bins according to star rating
--this is much faster than doing five searches with "and rating is"
repeat with possibleTrack in allTracks
copy (rating of possibleTrack)/20 as integer to starRating
if starRating is 5 then
copy possibleTrack to end of fiveStars
else if starRating is 4 then
copy possibleTrack to end of fourStars
else if starRating is 3 then
copy possibleTrack to end of threeStars
else if starRating is 2 then
copy possibleTrack to end of twoStars
else if starRating is 1 then
copy possibleTrack to end of oneStars
else
copy possibleTrack to end of noStars
end if
end repeat
end tell
--collect the top tracks
set topTracks to {}
getTracks(fiveStars)
getTracks(fourStars)
getTracks(threeStars)
getTracks(twoStars)
getTracks(oneStar)
getTracks(noStars)
--play the tracks, if any
if (count of topTracks) > 0 then
tell application "iTunes"
repeat with topTrack in topTracks
set topTrackID to the persistent ID of topTrack
play topTrack
--wait until this song is no longer playing, then go to the next
repeat while the persistent ID of current track is topTrackID
--delay a tenth of a second to avoid too much of the next random track
delay 0.1
end repeat
end repeat
end tell
end if
--add more tracks from the given trackList, until topCount is reached
--within a list, the choice of which tracks to use to reach topCount is somewhat arbitrary
on getTracks(trackList)
global topTracks, topCount
if (count of topTracks) ≥ topCount then return
repeat with possibleTrack in trackList
if (count of topTracks) ≥ topCount then
return
end if
copy possibleTrack to end of topTracks
end repeat
end getTracks
その他のオプションは、the duration of topTrack as number
のために遅延などがあります。トラックが変更されたときに通知を受け取るハンドラを設定することもできます。
この大きな回答に非常に感謝します。しかし、私のライブラリからではなく、Apple Musicリストからトラックを入手できますか? –
私はそうは思わない。しかし、あなたの最初のステップは、「アーティストのトップ・ソング」が意味するものをより明確に定義する必要があります。つまり、曲を演奏するために満たさなければならない基準は何ですか?この例に達するために取った手順と例を提供するのに役立つかもしれません。いったんこれを行うと、iTunesを使用しているソリューションやその他のメカニズムを使用したソリューションが明らかになることがあります。 –
iTunesには特別な段落「トップソング」があり、このリストを取得したいと考えています。しかし、あるアーティストのランダムな曲のリストを手に入れることもできます。 –
- 1. Spotify webAPIを使用して、アーティスト(ID)のランダムアルバムを再生する
- 2. 次の曲を自動再生する
- 3. 特定のアーティストから曲を入手するには?
- 4. フラッシュ - フラッシュプロジェクトの編集中に、曲の再生を再開する
- 5. Android Media Player OncompletionListener次の曲を再生しますが、2番目の曲は再生しません。
- 6. モデルに関連する(各曲には各アーティストが必要)
- 7. Spotify API:曲の特定の部分を再生する
- 8. 現在再生中の曲の情報を取得するOSX
- 9. 現在の再生曲のリストを取得するWindows phone 7
- 10. Spotifyアプリケーションの現在の再生キューに曲を追加する
- 11. avaudioplayerで次の曲を再生する際の問題
- 12. のAppleScript再フォーマット日付
- 13. Silverlightを使用してユーザーの曲を再生する
- 14. CocosDenshionを使ってiPodライブラリの曲を再生する
- 15. jPlayer曲の再生開始時にスクリプトを実行する
- 16. AndroidのSDカードから曲を選んで再生します。
- 17. C#:AxWMPLib - 曲の一部を再生する
- 18. Androidで特定の時間に曲を再生するには?
- 19. Androidのは、曲を再生リストビュー項目が
- 20. Android:MediaPlayerクラスの問題、曲を再生しない
- 21. Windows Media Playerで現在再生中の曲を取得
- 22. ウェブページでサウンドクラウドの曲を再生できない
- 23. iOSで複数の曲を再生する
- 24. itunesの曲が再生されている間の録音
- 25. ボタンを押して別の曲を再生するときに再生中の曲を停止させる機能を構築したい
- 26. Spotify API:jQuery/ajaxを使用して曲/アーティスト/アルバム情報を取得する
- 27. サービスを使用して曲を再生する方法
- 28. 発信者を保留にして曲を再生する
- 29. VB.Netマイクを通してMp3曲を再生する
- 30. 再生中の曲に曲の説明を追加しようとしています
"トップソング"はどのように定義しますか?最高の演奏数を持つ曲は? –
@ oa- iTunesで特別なパラグラフ「トップソング」があります –