Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support for IINA on AppleScript #539

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CarterLi
Copy link

基于官方仓库的PR在一个非官方的IINA版本上添加了AppleScript支持.

$ sdef /Applications/IINA.app
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary xmlns:xi="http://www.w3.org/2003/XInclude" title="IINA Terminonogy">
  <suite name="Standard Suite" code="****" description="Common classes and commands for all applications.">

    <command name="open" code="aevtodoc" description="Open a file.">
      <direct-parameter description="The file(s) to open.">
        <type type="file"/>
        <type type="file" list="yes"/>
      </direct-parameter>
    </command>

    <command name="close" code="coreclos" description="Close a document.">
      <cocoa class="NSCloseCommand"/>
      <access-group identifier="*"/>
      <direct-parameter type="specifier" requires-access="r" description="the document(s) or window(s) to close."/>
    </command>

    <command name="quit" code="aevtquit" description="Quit the application.">
      <cocoa class="NSQuitCommand"/>
    </command>

    <command name="count" code="corecnte" description="Return the number of elements of a particular class within an object.">
      <cocoa class="NSCountCommand"/>
      <access-group identifier="*"/>
      <direct-parameter type="specifier" requires-access="r" description="The objects to be counted."/>
      <parameter name="each" code="kocl" type="type" optional="yes" description="The class of objects to be counted." hidden="yes">
        <cocoa key="ObjectClass"/>
      </parameter>
      <result type="integer" description="The count."/>
    </command>

    <command name="exists" code="coredoex" description="Verify that an object exists.">
      <cocoa class="NSExistsCommand"/>
      <access-group identifier="*"/>
      <direct-parameter type="any" requires-access="r" description="The object(s) to check."/>
      <result type="boolean" description="Did the object(s) exist?"/>
    </command>

    <class name="application" code="capp" description="The application's top-level scripting object.">
      <cocoa class="NSApplication"/>
      <property name="name" code="pnam" type="text" access="r" description="The name of the application."/>
      <property name="frontmost" code="pisf" type="boolean" access="r" description="Is this the active application?">
        <cocoa key="isActive"/>
      </property>
      <property name="version" code="vers" type="text" access="r" description="The version number of the application."/>
      <element type="document">
        <cocoa key="orderedDocuments"/>
      </element>
      <element type="window" access="r">
        <cocoa key="orderedWindows"/>
      </element>
      <responds-to command="open">
        <cocoa method="handleOpenScriptCommand:"/>
      </responds-to>
      <responds-to command="print">
        <cocoa method="handlePrintScriptCommand:"/>
      </responds-to>
      <responds-to command="quit">
        <cocoa method="handleQuitScriptCommand:"/>
      </responds-to>
    </class>

    <class name="window" code="cwin" description="A window.">
      <cocoa class="NSWindow"/>
      <property name="name" code="pnam" type="text" access="r" description="The title of the window.">
        <cocoa key="title"/>
      </property>
      <property name="id" code="ID  " type="integer" access="r" description="The unique identifier of the window.">
        <cocoa key="uniqueID"/>
      </property>
      <property name="index" code="pidx" type="integer" description="The index of the window, ordered front to back.">
        <cocoa key="orderedIndex"/>
      </property>
      <property name="bounds" code="pbnd" type="rectangle" description="The bounding rectangle of the window.">
        <cocoa key="boundsAsQDRect"/>
      </property>
      <property name="closeable" code="hclb" type="boolean" access="r" description="Does the window have a close button?">
        <cocoa key="hasCloseBox"/>
      </property>
      <property name="miniaturizable" code="ismn" type="boolean" access="r" description="Does the window have a minimize button?">
        <cocoa key="isMiniaturizable"/>
      </property>
      <property name="miniaturized" code="pmnd" type="boolean" description="Is the window minimized right now?">
        <cocoa key="isMiniaturized"/>
      </property>
      <property name="resizable" code="prsz" type="boolean" access="r" description="Can the window be resized?">
        <cocoa key="isResizable"/>
      </property>
      <property name="visible" code="pvis" type="boolean" description="Is the window visible right now?">
        <cocoa key="isVisible"/>
      </property>
      <property name="zoomable" code="iszm" type="boolean" access="r" description="Does the window have a zoom button?">
        <cocoa key="isZoomable"/>
      </property>
      <property name="zoomed" code="pzum" type="boolean" description="Is the window zoomed right now?">
        <cocoa key="isZoomed"/>
      </property>
      <property name="document" code="docu" type="document" access="r" description="The document whose contents are displayed in the window."/>
      <responds-to command="close">
        <cocoa method="handleCloseScriptCommand:"/>
      </responds-to>
      <responds-to command="print">
        <cocoa method="handlePrintScriptCommand:"/>
      </responds-to>
      <responds-to command="save">
        <cocoa method="handleSaveScriptCommand:"/>
      </responds-to>
    </class>

  </suite>

  <suite name="IINA Suite" code="IINA" description="Classes and commands specific to IINA.">

    <enumeration name="player state" code="ePSt">
      <enumerator name="playing" code="kPSP" description="Playback is playing."/>
      <enumerator name="paused" code="kPSp" description="Playback is paused."/>
      <enumerator name="seeking" code="kPSS" description="The player is seeking."/>
    </enumeration>

    <command name="play" code="IINAPlay" description="Begin or resume playback.">
      <cocoa class="IINA.PlayCommand"/>
      <direct-parameter description="The player." optional="yes" hidden="yes">
        <type type="player"/>
      </direct-parameter>
    </command>

    <command name="pause" code="IINAPaus" description="Pause playback.">
      <cocoa class="IINA.PauseCommand"/>
      <direct-parameter description="The player." optional="yes" hidden="yes">
        <type type="player"/>
      </direct-parameter>
    </command>

    <command name="playpause" code="IINAPlPs" description="Toggle the playing/paused state of the player.">
      <cocoa class="IINA.PlayPauseCommand"/>
      <direct-parameter description="The player." optional="yes" hidden="yes">
        <type type="player"/>
      </direct-parameter>
    </command>

    <command name="next item" code="IINANext" description="Advance to the next playlist item.">
      <cocoa class="IINA.NextCommand"/>
      <direct-parameter description="The player." optional="yes" hidden="yes">
        <type type="player"/>
      </direct-parameter>
    </command>

    <command name="previous item" code="IINAPrev" description="Return to the previous playlist item.">
      <cocoa class="IINA.PreviousCommand"/>
      <synonym name="prev item"/>
      <direct-parameter description="The player." optional="yes" hidden="yes">
        <type type="player"/>
      </direct-parameter>
    </command>

    <command name="next frame" code="IINANxFr" description="Advance to the next frame.">
      <cocoa class="IINA.NextFrameCommand"/>
      <direct-parameter description="The player." optional="yes" hidden="yes">
        <type type="player"/>
      </direct-parameter>
    </command>

    <command name="previous frame" code="IINAPrFr" description="Return to the previous frame.">
      <cocoa class="IINA.PreviousFrameCommand"/>
      <synonym name="prev frame"/>
      <direct-parameter description="The player." optional="yes" hidden="yes">
        <type type="player"/>
      </direct-parameter>
    </command>

    <class name="player" code="cPla">
      <cocoa class="IINA.PlayerCore"/>

      <property name="id" code="ID  " description="The unique ID of the player." type="text" access="r">
        <cocoa key="uniqueID"/>
      </property>

      <property name="name" code="pnam" description="The name of the player." type="text" access="r">
        <cocoa key="scriptingName"/>
      </property>

      <property name="state" code="pSta" description="The playback state." type="player state" access="r">
        <cocoa key="scriptingState"/>
      </property>

      <property name="playback speed" code="pSpe" description="The playback speed." type="real" access="rw">
        <cocoa key="scriptingPlaySpeed"/>
      </property>

      <property name="file loop" code="pFLp" description="The file loop setting." type="boolean" access="rw">
        <cocoa key="scriptingFileLoop"/>
      </property>

      <property name="audio volume" code="pVol" description="The audio output volume (0 = minimum, 150 = maximum, 100 = normal)." type="integer" access="rw">
        <cocoa key="scriptingVolume"/>
      </property>

      <property name="muted" code="pMut" description="Has the audio output been muted?" type="boolean" access="rw">
        <cocoa key="scriptingIsMuted"/>
      </property>

      <property name="position" code="pPos" description="The playback position in seconds." type="real" access="rw">
        <cocoa key="scriptingPosition"/>
      </property>

      <property name="file" code="pFil" description="The currently playing file." type="file" access="r">
        <cocoa key="scriptingFile"/>
      </property>

      <property name="URL" code="pURL" description="The playing url." type="text" access="r">
        <cocoa key="scriptingUrlString"/>
      </property>

      <property name="music mode" code="pMin" description="Is the player in music mode?" type="boolean" access="rw">
        <cocoa key="scriptingIsInMiniPlayer"/>
      </property>

      <property name="fullscreen" code="pFSc" description="Is the player in fullscreen?" type="boolean" access="rw">
        <cocoa key="scriptingIsFullscreen"/>
      </property>

      <property name="window" code="pWin" description="The player’s currently visible window." type="window" access="r">
        <cocoa key="scriptingWindow"/>
      </property>

      <property name="current video track" code="pCVT" description="The index of the current video track." type="video track" access="rw">
        <cocoa key="scriptingCurrentVideoTrack"/>
      </property>

      <property name="current audio track" code="pCAT" description="The index of the current audio track." type="audio track" access="rw">
        <cocoa key="scriptingCurrentAudioTrack"/>
      </property>

      <property name="current subtitle track" code="pCST" description="The index of the current subtitle track." type="subtitle track" access="rw">
        <cocoa key="scriptingCurrentSubtitleTrack"/>
      </property>

      <property name="second subtitle track" code="pCsT" description="The index of the second subtitle track." type="subtitle track" access="rw">
        <cocoa key="scriptingSecondSubtitleTrack"/>
      </property>

      <property name="aspect ratio" code="pAsR" description="The curent aspect ratio." type="text" access="rw">
        <cocoa key="scriptingAspectRatio"/>
      </property>

      <property name="rotation" code="pRot" description="The current video rotation in degrees." type="integer" access="rw">
        <cocoa key="scriptingRotation"/>
      </property>

      <property name="mirrored" code="pMir" description="Whether the video is mirrored (horizontally)." type="boolean" access="rw">
        <cocoa key="scriptingMirror"/>
      </property>

      <property name="flipped" code="pFli" description="Whether the video is flipped (vertically)." type="boolean" access="rw">
        <cocoa key="scriptingFlip"/>
      </property>

      <property name="pip" code="pPIP" description="Is the player in picture-in-picture mode? (macOS 10.12+)" type="boolean" access="rw">
        <cocoa key="scriptingIsPIP"/>
      </property>

      <property name="current playlist item" code="pPLI" description="The current playlist item." type="playlist item" access="rw">
        <cocoa key="scriptingCurrentPlaylistItem"/>
      </property>


      <element type="track" description="The media tracks of the current media resource." access="r">
        <cocoa key="scriptingTracks"/>
      </element>

      <element type="video track" description="The video tracks of the current media resource." access="r">
        <cocoa key="scriptingVideoTracks"/>
      </element>

      <element type="audio track" description="The audio tracks of the current media resource." access="r">
        <cocoa key="scriptingAudioTracks"/>
      </element>

      <element type="subtitle track" description="The subtitle tracks of the current media resource." access="r">
        <cocoa key="scriptingSubtitleTracks"/>
      </element>

      <element type="playlist item" description="The items in the player’s playlist." access="r">
        <cocoa key="scriptingPlaylistItems"/>
      </element>


      <responds-to command="play">
        <cocoa method="handlePlayCommand:"/>
      </responds-to>

      <responds-to command="pause">
        <cocoa method="handlePauseCommand:"/>
      </responds-to>

      <responds-to command="playpause">
        <cocoa method="handlePlayPauseCommand:"/>
      </responds-to>

      <responds-to command="next item">
        <cocoa method="handleNextCommand:"/>
      </responds-to>

      <responds-to command="previous item">
        <cocoa method="handlePreviousCommand:"/>
      </responds-to>

      <responds-to command="next frame">
        <cocoa method="handleNextFrameCommand:"/>
      </responds-to>

      <responds-to command="previous frame">
        <cocoa method="handlePreviousFrameCommand:"/>
      </responds-to>

      <responds-to command="close">
        <cocoa method="handleCloseCommand:"/>
      </responds-to>

    </class>

    <enumeration name="track type" code="eTrT">
      <enumerator name="video" code="kTTV" description="Video track."/>
      <enumerator name="audio" code="kTTA" description="Audio track."/>
      <enumerator name="subtitle" code="kTTS" description="Subtitle track."/>
    </enumeration>

    <class name="track" description="A media track." code="cTra">
      <cocoa class="IINA.MPVTrack"/>

      <property name="type" code="pTyp" type="track type" access="r">
        <cocoa key="scriptingType"/>
      </property>

      <property name="codec" code="pCdc" type="text" access="r">
        <cocoa key="scriptingCodec"/>
      </property>

      <property name="language" code="pLng" type="text" access="r">
        <synonym name="lang"/>
        <cocoa key="scriptingLanguage"/>
      </property>

      <property name="name" code="pnam" type="text" access="r">
        <cocoa key="scriptingTitle"/>
      </property>

      <property name="info string" code="pISt" type="text" access="r">
        <cocoa key="scriptingInfoString"/>
      </property>

      <property name="default" code="pDef" type="boolean" access="r">
        <cocoa key="scriptingIsDefault"/>
      </property>

      <!-- Properties only exposed by subtypes. Included here so they resolve properly. -->

      <property name="fps" code="pFPS" type="real" access="r" hidden="yes">
        <cocoa key="scriptingFPS"/>
      </property>

      <property name="width" code="pWid" type="integer" access="r" hidden="yes">
        <cocoa key="scriptingWidth"/>
      </property>

      <property name="height" code="pHei" type="integer" access="r" hidden="yes">
        <cocoa key="scriptingHeight"/>
      </property>

      <property name="sample rate" code="pSam" type="integer" access="r" hidden="yes">
        <cocoa key="scriptingSampleRate"/>
      </property>

      <property name="channel count" code="pCha" type="integer" access="r" hidden="yes">
        <cocoa key="scriptingChannelCount"/>
      </property>

    </class>

    <class name="video track" description="An video media track."  code="cTrV" inherits="track">
      <cocoa class="IINA.MPVTrack"/>

      <property name="fps" code="pFPS" type="real" access="r">
        <cocoa key="scriptingFPS"/>
      </property>

      <property name="width" code="pWid" type="integer" access="r">
        <cocoa key="scriptingWidth"/>
      </property>

      <property name="height" code="pHei" type="integer" access="r">
        <cocoa key="scriptingHeight"/>
      </property>

    </class>

    <class name="audio track" description="An audio media track." code="cTrA" inherits="track">
      <cocoa class="IINA.MPVTrack"/>

      <property name="sample rate" code="pSam" type="integer" access="r">
        <cocoa key="scriptingSampleRate"/>
      </property>

      <property name="channel count" code="pCha" type="integer" access="r">
        <cocoa key="scriptingChannelCount"/>
      </property>

    </class>

    <class name="subtitle track" description="An subtitle media track." code="cTrS" inherits="track">
      <cocoa class="IINA.MPVTrack"/>
      <synonym name="sub track"/>
    </class>

    <class name="playlist item" description="An item in a playlist." code="cPLI">
      <cocoa class="IINA.MPVPlaylistItem"/>

      <property name="file" code="pFil" type="file" access="r">
        <cocoa key="scriptingFile"/>
      </property>

      <property name="URL" code="pURL" type="text" access="r">
        <cocoa key="scriptingURLString"/>
      </property>

      <property name="name" code="pnam" type="text" access="r">
        <cocoa key="scriptingName"/>
      </property>

      <property name="current" code="pCur" type="boolean" access="r">
        <cocoa key="scriptingIsCurrent"/>
      </property>

      <property name="currently playing" code="pPly" type="boolean" access="r">
        <cocoa key="scriptingIsPlaying"/>
      </property>

      <property name="network" code="pNet" type="boolean" access="r">
        <cocoa key="scriptingIsNetworkResource"/>
      </property>

    </class>

    <class-extension description="The IINA Application" extends="application">

      <cocoa class="NSApplication"/>
      <element type="player" access="r">
        <cocoa key="orderedPlayers"/>
      </element>

    </class-extension>
  </suite>
</dictionary>

我也尝试参考现有代码给LyricsX添加IINA的支持,但是由于众所周知的网络问题我下载依赖包一直失败,尝试好几次之后放弃了。这个PR包含了一些初始代码(由于依赖的问题项目起不起来所以未测试),希望能有所帮助

@CarterLi
Copy link
Author

包含AppleScript支持的IINA包可以在这里下载:https://github.com/iina-plus/iina#binaries

@ddddxxx
Copy link
Owner

ddddxxx commented Jan 11, 2022

你好,感谢支持!大致看了一下你修改的地方,都没有问题。这里只包含 UI 方面的改动,实际和播放器的交流发生在 https://github.com/ddddxxx/MusicPlayer 。我稍后会向 IINA 方面求证,如果 sdef 文件将来不会大改的话,我可以完成这部分工作。

鉴于你可以完整编译 IINA,我猜测不是网络问题导致无法编译。可能和 #331 有关,可以请你贴出错误报告吗?

@CarterLi
Copy link
Author

你好,感谢支持!大致看了一下你修改的地方,都没有问题。这里只包含 UI 方面的改动,实际和播放器的交流发生在 https://github.com/ddddxxx/MusicPlayer 。我稍后会向 IINA 方面求证,如果 sdef 文件将来不会大改的话,我可以完成这部分工作。

鉴于你可以完整编译 IINA,我猜测不是网络问题导致无法编译。可能和 #331 有关,可以请你贴出错误报告吗?

就是fetch什么仓库等半天没反应后面就失败了
特别是微软的一个库,好几次都卡在这个库上面

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants