2014-07-12 3 views
0

우리 모두 iTunes의 Doug의 applescript를 알고 있습니다. 그러나 스트리밍 음악의 성장으로 더 이상 iTunes를 사용하지 않고 Spotify를 사용합니다.Spotify의 노래 미리보기 Applescript - NeedleDrop from Doug

나는 노래를 미리보기 위해 NeedleDrop 스크립트를 적용하려고했습니다. 스크립트는 설정할 수 있습니다

a - 주어진 시간부터 시작, f.e. 30 초에 곡 재생 시작 b - 지정된 시간 동안 해당 곡 재생, f.e. 10 초.

스크립트가 주어진 시간에 첫 번째 노래를 시작하고 주어진 시간 동안 재생되지만 다음 노래는 주어진 시간 동안 재생되지만 주어진 시간 값 대신 처음부터 시작하는 것이 문제입니다.

이 스크립트는 Doug의 GNU 라이센스하에 있으며 라이센스가 포함되어 있습니다. 스크립트와 내 보낸 앱을 게시하고 있습니다. 누구나 아이디어가 있다면?!

LINK : Download 여기

이 다운로드 파일에서 제공하는 스크립트입니다

-- handler to get a number from user 
to get_a_number(pmpt, addenda, defnum) 
    set rez to (display dialog addenda & pmpt default answer defnum buttons {"Cancel ", "OK"}   default button 2 with title "Needle Drop") 
    if button returned of rez starts with "cancel" then tell me to quit 
    set myNumber to text returned of rez 
    try 
     if myNumber is "" then get_a_number(pmpt, "Enter only numbers..." & return & return, defnum) 
     return (myNumber as integer) 
    on error -- m number n 
     get_a_number(pmpt, "Enter only numbers..." & return & return, defnum) 
    end try 
end get_a_number 

global start_time -- seconds into each track to begin playing 
global needle_drop_interval -- seconds to play each track 

on run 
-- get number of seconds between songs 
    set needle_drop_interval to my get_a_number("Play each track for how many seconds?", "", "10") 
-- get seconds into each track to play 
    set start_time to my get_a_number("How many seconds into each track to start playing?", "", "10") 

-- play first song in the playlist 
    tell application "Spotify" 
     activate 
     set player position to start_time 
     play 
     delay needle_drop_interval 
    end tell 
end run 

on idle 
    tell application "Spotify" 
     if player state is not playing then tell me to quit 
     pause 
     next track 
     set player position to start_time 
     play 
    end tell 
return needle_drop_interval 
end idle 

on quit 
    try 
     tell application "Spotify" to stop 
    end try 
    continue quit 
    error number -128 
end quit 

답변

0

놀라운 사이의 행 스위치!

그러나 일부 노래가 끝난 후에도 버그가 계속 발생하는 경우가 종종 있는데, 플레이어의 위치가 설정되기 전에 지연이 추가되어 완전히 수정 된 것 같습니다.

이것은 모순적인 것처럼 들릴 수도 있지만 나를 위해 더 잘 작동합니다.

감사합니다.

on idle 
    tell application "Spotify" 
     if player state is not playing then tell me to quit 
     next track 
     pause 
     delay 1 
     set player position to start_time 
     play 
    end tell 
    return needle_drop_interval 
end idle 
1

제공되는 스크립트가 스트리밍 사람을위한 오프라인 재생 목록 미세하지만 작동합니다. Spotify는 아마도 트랙이나 다른 것을 버퍼링 할 시간이 없을 것입니다.

지연을 추가하여 버퍼링 시간을 단축 시켰을 때 정상적으로 작동했습니다. (당신은 더 짧고 더 이상 지연 실험 할 수)

tell application "Spotify" 
    if player state is not playing then tell me to quit 
    next track 
    pause 
    set player position to start_time 
    delay 1 
    play 
end tell 

주 '다음 트랙'과 '일시 정지'

+0

죄송합니다. 저는 Stack에 상당히 익숙합니다. 답변을 투표 할 수 없습니다. 주요 질문에 답했다. 감사 & 환호 – Bodysoulspirit

+0

나는 내 웹 사이트에 작은 응용 프로그램을 배포하고 도움을 주셔서 감사합니다. 나는 그것을 제거하거나 원하는 경우 다른 링크로 변경할 수 있습니다. 환호 -> http://bodysoulspirit.weebly.com/prefy.html – Bodysoulspirit

+0

내 아침을 멋지게 만들었습니다! :디 – Rusty