1. Diese Seite verwendet Cookies. Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies. Weitere Informationen

VLC Now playing

Dieses Thema im Forum "AppleScript" wurde erstellt von Anacotic, 20.06.09.

  1. Anacotic

    Anacotic Braeburn

    Dabei seit:
    10.07.08
    Beiträge:
    43
    Hi,

    und zwar suche ich ein "Now Playing" Script für den VLC Player ähnlich wie das was es für Adium/Linkinus bereits als iTunes Version gibt, also dass Der Titel und die Aktuelle Position Ausgegeben wird...

    BSP: Ich schaue Königin der Verdammten 00:10:32/01:30:23
    oder so ähnlich...

    würde mich freuen wenn mir jemand helfen kann.

    EDIT: hab was gefunden, das funktioniert aber leider nicht, bekomme immer die Ausgabe "Ich schaue gerade nichts" egal ob ein Video läuft oder nicht.

    Code:
    linkinuscmd()
    
    on linkinuscmd()
        -- Obtain the player state and video title.
        set theState to getTheState()
        set theTitle to str_replace("_", " ", getTheTitle())
        
        -- Check if the VLC state was determined to be "playing".
        if theState is "playing" then
            if theTitle is not "" then
                
                -- Return what is most likely the title.
                return "Ich schaue gerade: " & theTitle
            end if
        end if
        
        -- None of the above is true... :(
        return "Ich schaue gerade nichts"
    end linkinuscmd
    
    on getTheState()
        -- Initialise the return value.
        set theState to ""
        
        -- Try and obtain the current state.
        try
            tell application "System Events"
                tell process "VLC"
                    tell menu 1 of menu bar item "Playback" of menu bar 1
                        get title of menu item 1
                        set play_pause_btn to the result
                        get enabled of menu item 2
                        set stop_enabled to result
                    end tell
                end tell
            end tell
            
            -- We're only interested if VLC is playing.
            if stop_enabled is true and play_pause_btn is "pause" then
                set theState to "playing"
            end if
        end try
        
        -- Return the state.
        return theState
    end getTheState
    
    on getTheTitle()
        -- Initialise the return value.
        set theTitle to ""
        
        -- Try and obtain the title of the playing window.
        try
            tell application "VLC"
                set theTitle to name of first window whose id is not -1 and name is not "VLC media player" and zoomable is true
            end tell
            display dialog Le_titre
        end try
        
        -- Return the title.
        return theTitle
    end getTheTitle
    
    on str_replace(find, replace, subject)
        set prevTIDs to text item delimiters of AppleScript
        set returnList to true
        
        if class of find is not list and class of replace is list then return subject
        if class of find is not list then set find to {find}
        if class of subject is not list then set {subject, returnList} to {{subject}, false}
        
        set findCount to count find
        set usingReplaceList to class of replace is list
        
        try
            repeat with i from 1 to (count subject)
                set thisSubject to item i of subject
                
                repeat with n from 1 to findCount
                    set text item delimiters of AppleScript to item n of find
                    set thisSubject to text items of thisSubject
                    
                    if usingReplaceList then
                        try
                            item n of replace
                        on error
                            "" -- `replace` ran out of items
                        end try
                    else
                        replace
                    end if
                    
                    set text item delimiters of AppleScript to result
                    set thisSubject to "" & thisSubject
                end repeat
                
                set item i of subject to thisSubject
            end repeat
        end try
        
        set text item delimiters of AppleScript to prevTIDs
        if not returnList then return beginning of subject
        return subject
    end str_replace
     
  2. AgentSmith

    AgentSmith Hochzeitsapfel

    Dabei seit:
    15.07.07
    Beiträge:
    9.361
    Ich war mal eben so frei. Gibt allerdings nix weiter aus als den Dateinamen.

    Code:
    on linkinuscmd(cmd)
    	-- Let's see  if VLC is around..
    	set AppleScript's text item delimiters to ""
    	set vlc_active to false
    	set theString to "/me is not currently running VLC."
    	
    	tell application "Finder"
    		if (get name of every process) contains "VLC" then set vlc_active to true
    	end tell
    	
    	if vlc_active then
    		
    		-- Ok, VLC is running.  Let's find out what's playing...
    		try
    			tell application "System Events"
    				tell process "VLC"
    					tell menu 1 of menu bar item "Wiedergabe" of menu bar 1
    						get title of menu item 1
    						set play_pause_btn to the result
    						get enabled of menu item 2
    						set stop_enabled to result
    					end tell
    				end tell
    			end tell
    			
    			set theString to "/me is currently not playing anything in VLC."
    			
    			-- We're only interested if VLC is playing.
    			if stop_enabled is true and play_pause_btn is "pause" then
    				try
    					tell application "VLC"
    						set theTitle to name of first window whose id is not -1 and name is not "VLC media player" and zoomable is true
    						set theString to "/me is running VLC: " & theTitle
    					end tell
    				end try
    			end if
    		end try
    		
    	end if -- end of VLC being active
    	
    	return theString
    end linkinuscmd
    
     
    #2 AgentSmith, 02.10.09
    Zuletzt bearbeitet: 02.10.09
  3. Eigeninitiative

    Eigeninitiative Golden Delicious

    Dabei seit:
    13.06.11
    Beiträge:
    10
    Hab mal eine Frage.
    Und wie läuft das jetzt mit diesem Code ?
    Was mache ich mit dem ? Und wie bekomme ich den in Adium ?

    Danke
     

Diese Seite empfehlen