Jump to content
Sign in to follow this  
mathew

Windows Media Player Control

Recommended Posts

mathew

Hey,

is there any way to control the Windows Media Player?

I just want to add files (I have the path of them) to the

actual playlist. Its ment for a party. My laptop accepts

datatransfer via bluetooth. A AutoIt script should scan

the default savedirectory whether there is a new file,

move it to another folder and add it to the playlist.

Everything workes besides the adding to the playlist.

May someone help me please?

Thanks for answers.

Best Regards,

Matthias

Share this post


Link to post
Share on other sites
Szhlopp

Hey,

is there any way to control the Windows Media Player?

I just want to add files (I have the path of them) to the

actual playlist. Its ment for a party. My laptop accepts

datatransfer via bluetooth. A AutoIt script should scan

the default savedirectory whether there is a new file,

move it to another folder and add it to the playlist.

Everything workes besides the adding to the playlist.

May someone help me please?

Thanks for answers.

Best Regards,

Matthias

This isn't 100% what you need. However, it does do what it's supposed to.

ALL this does is edit the .wpl media player uses to include another file. It doesn't refresh WMP though, so you may need to click the list or find some way to make itself refresh what it has.

#include <File.au3>
;
_WMPlaylistAdd("Convertlist3", "E:\NapsterDownloads\Thousand Foot Krutch\The Art of Breaking\Thousand Foot Krutch - Breathe You In.wma")


Func _WMPlaylistAdd($sPlaylist, $sTrack)
    Local $Path
    
    ; Get the path
    If FileExists(@UserProfileDir & '\music\playlists\' & $sPlaylist & ".wpl") = 1 Then 
        $Path = @UserProfileDir & '\music\playlists\' & $sPlaylist & ".wpl"
    ElseIf FileExists($sPlaylist) = 1 Then
        $Path = $sPlaylist
    Else
        SetError(1)
        Return 0
    EndIf
    
    ;Read it
    $FileText = FileRead($Path)
    
    ; Get the items
    $CurrentItems = StringRegExp($FileText, '<media src="(.*?)"', 3)
    
    $FirstHalf = StringSplit($FileText, "<seq>", 1)
    $FirstHalf = $FirstHalf[1] & "<seq>" & @CRLF
    
    For $I = 0 To UBound($CurrentItems) - 1
        $FirstHalf &= '            <media src="' & $CurrentItems[$I] & '"/>' & @CRLF
    Next
    
    ; Add in the new item
    $FirstHalf &= '            <media src="' & $sTrack & '"/>' & @CRLF
    $FirstHalf &= '        </seq>' & @CRLF & '    </body>' & @CRLF & '</smil>' & @CRLF
    
    FileDelete($Path)
    FileWrite($Path, $FirstHalf)
    
    
EndFunc

1 param - Playlist name OR complete playlist path

2 param - Complete path to the file you want to add

Good luck man. Sorry I can't do more!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.