« BTMNotificationAgent | トップページ | prefPaneはSystem Settingsに »

[Music]フェードアウト からの フェードイン ボリュームを戻す版

sound volume を 100に基準ではなくて
スクリプトを実行したタイミングの音量を元に
フェードアウトフェードインで次の曲へ

【スクリプトエディタで開く】

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
#   com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


####1曲何秒聴く?
set numTimer to 30 as integer

###何曲
set numCntRep to 5000 as number

####何曲目
set numCnt to 0 as number

tell application "Music"
  set numVolume to sound volume
end tell


repeat numCntRep times
  
  tell application "Music"
    set sound volume to numVolume
    set objState to (player state)
    if objState is playing then
      log "再生中"
      set objNowTrack to current track
      
      set objNowTrack to current track
      name of objNowTrack as text
      album of objNowTrack as text
      artist of objNowTrack as text
      ##################
      delay numTimer
      ##################
      ###フェードアウト
      set sound volume to numVolume
      set numTempVolume to numVolume
      repeat 10 times
        set sound volume to numTempVolume
        set numTempVolume to (numTempVolume - (numVolume / 10)) as integer
        delay 0.1
      end repeat
      set sound volume to 0
      ##################
      ###次の曲
      next track
      ##################
      ###フェードイン
      set numVolume to numVolume as integer
      set sound volume to 0 as integer
      set numTempVolume to 0 as integer
      repeat 10 times
        set sound volume to numTempVolume
        set numTempVolume to (numTempVolume + (numVolume / 10)) as integer
        delay 0.1
      end repeat
      set sound volume to numVolume
    else if objState is paused then
      set sound volume to numVolume
      log "ポーズ中"
      try
        set objNowTrack to current track
        play
      on error
        exit repeat
      end try
    else if objState is stopped then
      set sound volume to 100
      log "停止中"
      try
        set objNowTrack to current track
        play
      on error
        exit repeat
      end try
    end if
  end tell
  
  set numCnt to (numCnt + 1) as number
  log numCnt
  ---リピートの終わり
end repeat




|

« BTMNotificationAgent | トップページ | prefPaneはSystem Settingsに »

AppleScript Music」カテゴリの記事