?? advanced.docbook
字號(hào):
<entry>void queueForTransfer( KURL url )</entry><entry>Queue file for transfer to Media Device.</entry></row><row><entry>void seek(int s)</entry><entry>Seek track to seconds position.</entry></row><row><entry>void seekRelative(int s)</entry><entry>Seek to a position relative to the current track position.</entry></row><row><entry>void setEqualizer(int, int, int, int, int, int, int, int, int, int, int)</entry><entry>Set the equalizer bands </entry></row><row><entry>void setEqualizerEnabled( bool active )</entry><entry>Toggle equalizer.</entry></row><row><entry>void setEqualizerPreset( QString name )</entry><entry>Set the equalizer preset </entry></row><row><entry>void setLyricsByPath( QString url, QString lyrics )</entry><entry>Set the lyrics of a track by it's path.</entry></row><row><entry>void setScore( int score )</entry><entry>Set the score of the currently playing track.</entry></row><row><entry>void setScoreByPath( QString url, int score )</entry><entry>Set the score of a track by it's path.</entry></row><row><entry>void setVolume(int volume)</entry><entry>Set volume in range 0-100%.</entry></row><row><entry>void showBrowser( QString browser )</entry><entry>Shows browsers in the playlist window</entry></row><row><entry>void showOSD()</entry><entry>Show the OSD display on the screen.</entry></row><row><entry>void stop()</entry><entry>Equivalent to pressing "Stop" button.</entry></row><row><entry>void transferDeviceFiles()</entry><entry>Transfer files to media device.</entry></row><row><entry>void volumeDown()</entry><entry>Decrease volume by a reasonable step.</entry></row><row><entry>void volumeUp()</entry><entry>Increase volume by a reasonable step.</entry></row></tbody></tgroup></informaltable></sect2><sect2 id="dcop-playlist"><title>dcop amarok playlist</title><informaltable><tgroup cols="2"><thead><row><entry>DCOP Call</entry><entry>Action</entry></row></thead><tbody><row><entry>int getActiveIndex()</entry><entry>Return the index of the currently active track. -1 if none.</entry></row><row><entry>int getTotalTrackCount()</entry><entry>Return number of tracks in playlist. 0 if none.</entry></row><row><entry>QString saveCurrentPlaylist()</entry><entry>Saves the current playlist to current.xml and returns its path.</entry></row><row><entry>void addMedia( KURL )</entry><entry>Add audio media specified by the url.</entry></row><row><entry>void addMediaList( KURL::List )</entry><entry>Add some audio media specified by the url.</entry></row><row><entry>void clearPlaylist()</entry><entry>Clears the playlist.</entry></row><row><entry>void playByIndex(int)</entry><entry>Starts playing the track at the specified index.</entry></row><row><entry>void playMedia( KURL )</entry><entry>Add audio media specified by the url.</entry></row><row><entry>void popupMessage( QString)</entry><entry>Shows a temporary popup message.</entry></row><row><entry>void removeCurrentTrack()</entry><entry>Removes the current-track item from the playlist.</entry></row><row><entry>void repopulate()</entry><entry>Repopulate the playlist with random tracks.</entry></row><row><entry>void saveM3u( QString path, bool relativePaths)</entry><entry>Saves the current playlist as m3u.</entry></row><row><entry>void setStopAfterCurrent( bool )</entry><entry>Enables/disables the "Stop After Current Track" feature.</entry></row><row><entry>void shortStatusMessage( QString)</entry><entry>Shows a temporary message on the statusbar.</entry></row><row><entry>void shufflePlaylist()</entry><entry>Shuffles the playlist.</entry></row><row><entry>void togglePlaylist()</entry><entry>Toggle the Playlist-window.</entry></row></tbody></tgroup></informaltable></sect2><sect2 id="dcop-playlistbrowser"><title>dcop amarok playlistbrowser</title><informaltable><tgroup cols="2"><thead><row><entry>DCOP Call</entry><entry>Action</entry></row></thead><tbody><row><entry>void addPodcast( QString )</entry><entry>Add a podcast entry to the playlist browser.</entry></row><row><entry>void scanPodcasts()</entry><entry>Scan all podcasts for updates.</entry></row><row><entry>void addPlaylist( QString )</entry><entry>Add a playlist to the playlist browser.</entry></row></tbody></tgroup></informaltable></sect2><sect2 id="dcop-script"><title>dcop amarok script</title><informaltable><tgroup cols="2"><thead><row><entry>DCOP Call</entry><entry>Action</entry></row></thead><tbody><row><entry>bool runScript( QString name)</entry><entry>Starts the script with the given name. Returns true on success.</entry></row><row><entry>bool stopScript( QString name)</entry><entry>Stops the script with the given name. Returns true on success.</entry></row><row><entry>QStringList listRunningScripts()</entry><entry>Returns a list of all currently running scripts.</entry></row><row><entry>void addCustomMenuItem(QString submenu, QString itemTitle )</entry><entry>Enables and sets custom menu item title.</entry></row><row><entry>void removeCustomMenuItem(QString submenu, QString itemTitle )</entry><entry>Removes the custom menu item.</entry></row><row><entry>QString readConfig( QString key)</entry><entry>Returns a AmarokConfig configuration entry value from the given key.</entry></row></tbody></tgroup></informaltable></sect2></sect1><sect1 id="cmd-line-options"><title>Command-line Options</title><para>Amarok supports the use of the standard Qt and kde command line options. Amarok also has it's own application specific options.</para><para>The Qt and kde options:</para><informaltable><tgroup cols="2"><thead><row><entry>Option</entry><entry>Action</entry></row></thead><tbody><row><entry>--help</entry><entry>Show help about options.</entry></row><row><entry>--help-qt</entry><entry>Show Qt specific options.</entry></row><row><entry>--help-kde</entry><entry>Show KDE specific options.</entry></row><row><entry>--help-all</entry><entry>Show all options.</entry></row><row><entry>--author</entry><entry>Show author information.</entry></row><row><entry>-v, --version</entry><entry>Show version information.</entry></row><row><entry>--license</entry><entry>Show license information.</entry></row></tbody></tgroup></informaltable><para>The Amarok options:</para><note><para>The &amarok; options are designed to be used while &amarok; is running.</para></note><informaltable><tgroup cols="2"><thead><row><entry>Option</entry><entry>Action</entry></row></thead><tbody><row><entry>-r, --previous</entry><entry>Skip to the previous track in the playlist.</entry></row><row><entry>-p, --play</entry><entry>Start playing current playlist.</entry></row><row><entry>-s, --stop</entry><entry>Stop playback.</entry></row><row><entry>--pause</entry><entry>Pause playback.</entry></row><row><entry>-f, --next</entry><entry>Skip to the next track in the playlist.</entry></row><row><entry>-a, --append</entry><entry>Append Files/URLs into the playlist.</entry></row><row><entry>-e, --enqueue</entry><entry>See append, available for backwards compatability.</entry></row><row><entry>--queue</entry><entry>Queue Files/URLs after the currently playing track.</entry></row><row><entry>-m, --toggle-playlist-window</entry><entry>Toggle the playlist window.</entry></row><row><entry>--wizard</entry><entry>Launch the First-run wizard.</entry></row><row><entry>--engine "name"</entry><entry>Start &amarok; with the "name" engine.</entry></row></tbody></tgroup></informaltable></sect1><sect1 id="script-writing"><title>Script Writing</title><para>Scripting allows you to extend &amarok; easily without changing the main codebase. Scripts are similar to plugins, but instead of a dedicated plugin API they use &amarok;'s DCOP interface for communication. This makes it possible to write scripts in almost any programming language, like Ruby, Python or PHP. Not only can you create scripts in classic scripting languages, but also in compiled languages like C++ or plain C. Additionally, &amarok; can notify the scripts on special events and make them react accordingly. This notification system will be explained later in this section.</para><sect2 id="script-bindings"><title>Bindings</title><para>It is possible to write simple scripts that do not need user interaction, and it's also possible to make scripts with comfortable GUIs that act like little applications of their own. For GUI programming one of the many bindings which KDE provides can be used, for instance RubyQt, a Qt library binding for Ruby. However, it is worth noting that not every user has all available bindings installed. If you decide to use a binding, try to use one of the relatively wide spread ones (e.g. RubyQt or PyQt).</para><para>In order to provide some feedback when a script fails to run due to a missing dependency, please check in your script if the module you want to include really exists. If the dependency is missing, you should catch the error and show an information dialog using the "kdialog" command line tool, so that the user learns why the script fails to run.</para><para>This example shows how to catch a missing dependency in Ruby:</para><programlisting>begin require 'Korundum'rescue LoadError error = 'Korundum (KDE bindings for ruby) from kdebindings v3.4 is required for this script.' `kdialog --sorry '#{error}'` exitend</programlisting></sect2><sect2 id="script-templates"><title>Getting Started: The Templates</title><para>&amarok; provides template scripts for several languages in the <filename class="directory">scripts/templates/</filename> directory. You can use these scripts as a basis for your own scripts, and extend them with the functionality you need. You'll notice that scripting is actually quite straightforward; For instance if you know to program a bit in Python, making your own script won't take you long.</para></sect2><sect2 id="script-controlling-amarok"><title>Controlling &amarok; With DCOP</title><para>Scripts can control Amarok by calling some of its DCOP functions. The easiest way to invoke a DCOP function is by using the "dcop" command line utility, which is part of every KDE distribution.</para><para>Here is an example for increasing the master volume:</para><programlisting>dcop amarok player volumeUp</programlisting><para>Most scripting languages allow to execute external programs, with a function like exec(). This way the "dcop" utility can be invoked easily. Here is a simple Python example:</para><programlisting> import os os.system("dcop amarok player volumeDown")</programlisting></sect2><sect2 id="script-notifications"><title>Notifications</title><para>&amarok; sends notifications to all running scripts by writing strings to their stdin channel. The script should therefore constantly monitor stdin, and react accordingly to each of the possible events. Scripts may also choose to ignore any event they don't have a use for.</para><para>The following notifications are sent by &amarok;:</para><programlisting><cmdsynopsis><command>configure</command></cmdsynopsis>Tells the script to show its configuration dialog. The script must handle thestoring and loading of configuration options by itself. When a script isstarted, Amarok sets its working directory to the folder where all datashould be stored.</programlisting><programlisting><cmdsynopsis><command>engineStateChange:</command><arg>empty|idle|paused|playing</arg></cmdsynopsis>Signals a change in the engine's state.</programlisting><programlisting><cmdsynopsis><command>trackChange</command></cmdsynopsis>Signals the start of a new track. The script may then use DCOP functions toquery further information about the track, e.g. metadata and the length.</programlisting><programlisting><cmdsynopsis><command>volumeChange</command><arg>newVolume</arg></cmdsynopsis>Signals a change of the master volume level. The volume is an integer with arange of 0-100.</programlisting><programlisting><cmdsynopsis><command>customMenuClicked:</command><arg>submenu itemTitle paths</arg></cmdsynopsis>Returns the paths to selected files in the playlist when the custom playlistcontext menu item is clicked. The submenu and itemTitle are also returned foridentification purposes in case a script is listening for multiple notifications.To insert an item into the context menu use the DCOP call'dcop amarok script addCustomMenuItem( submenu itemTitle )'. To remove anitem from the context menu use the DCOP call'dcop amarok script removeCustomMenuItem( submenu itemTitle )'.</programlisting></sect2><sect2 id="script-termination"><title>Script Termination</title><para>Before &amarok; exits, or when the user stops a script with the Script Manager, &amarok; sends the SIGTERM signal to the script. This signal can be caught in order to do cleanup work, like saving data or configuration settings.</para></sect2><sect2 id="script-packaging"><title>Packaging</title><para>&amarok;'s Script Manager is able to install script packages that the user has downloaded from a web server. Packages are just normal tarballs (.tar), optionally compressed with bzip2 (.bz2). We strongly recommend using a filename like myscript.amarokscript.tar.bz2, so the user can easily identify the package as an Amarok script.</para><note><para>&amarok; 1.3 will only accept script packages with the amarokscript extension, so it is better to use it right from the start.</para></note><para>The tarball's content must be organized as follows:</para><programlisting>myscript/ README myscript.py (executable) somemodule.py foo.data ...</programlisting></sect2><sect2 id="script-permissions"><title>File permissions</title><para>The main script must have executable (+x) permissions set, while additional modules which the script loads should not be executable. To preserve the file permissions in the tarball, you should use tar with the -p flag:</para><programlisting>tar -cf myscript.amarokscript.tar -p myscript</programlisting><note><para>&amarok; will not be able to install the script if the permissions are not correctly set.</para></note></sect2><sect2 id="script-distributing"><title>Distributing</title><para>When the package is finished, you can upload it to <ulink url="http://www.kde-apps.org">www.kde-apps.org</ulink>, and add the link to the &amarok; <ulink url="http://amarok.kde.org/amarokwiki/index.php/Scripts">Wiki Scripts Page</ulink>. For the kde-apps entry you should use the <ulink url="http://kde-apps.org/index.php?xcontentmode=56">&amarok; Scripts</ulink> category.</para></sect2></sect1></chapter>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -