Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.056 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'debug': 0.07; 'granted,': 0.07; 'tune': 0.09; 'url:github': 0.09; 'runs': 0.10; 'cc:addr :python-list': 0.11; 'project,': 0.12; 'assume': 0.14; 'windows': 0.15; "(it's": 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guys,': 0.16; 'guys?': 0.16; 'keys.': 0.16; 'subject:media': 0.16; 'subject:windows': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'import': 0.22; 'coding': 0.22; 'cc:addr:python.org': 0.22; 'driver': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'player': 0.26; 'post': 0.26; 'header:In-Reply- To:1': 0.27; 'ideal': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; 'fighting': 0.31; 'invoke': 0.31; 'option.': 0.31; 'terminate': 0.31; 'there.': 0.32; 'skip:m 30': 0.32; 'text': 0.33; 'plain': 0.33; 'sources': 0.33; 'device': 0.34; 'screen': 0.34; 'skip:d 20': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'doing': 0.36; 'similar': 0.36; 'wrong': 0.37; 'project': 0.37; 'manager': 0.38; 'audio': 0.38; 'driving': 0.38; 'process,': 0.38; 'files': 0.38; 'list,': 0.38; 'pm,': 0.38; 'anything': 0.39; 'does': 0.39; 'success.': 0.39; 'easy': 0.60; 'commands': 0.60; 'manually': 0.60; 'free': 0.61; 'full': 0.61; 'simply': 0.61; 'first': 0.61; 'here:': 0.62; 'back': 0.62; 'story': 0.63; 'laptop': 0.65; 'movie': 0.65; 'media': 0.66; 'watching': 0.68; 'fact,': 0.69; 'music': 0.75; 'borrow': 0.84; 'lan.': 0.84; 'subject:player': 0.84; 'toy': 0.84; 'worth,': 0.84; 'to:none': 0.92; 'room,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=2jeiCXeZ3WRWOzEcmRl2OuuZdSVUVU+DJldLtGlZbL0=; b=az3v10kyXwVFEY2BGgBk+cCWvZQgmBTqQSGA0QyPsJNyCwS7BzQrhCjOfu9k2ps8ZR YZ48bxz69T90uKMLLeLh301hLrmlsRlh/HsTmv8p2+q94kmdtBzUwlDLivf3yZsNZOBp ut48UM6NmnMKLylX4yqQUDCSQmJdkTgB1VF1JF3MvsnrlFUR9k8hqC/MJvcGYM3gc7qJ 4kvpGMJ9DDub4ojbLbs+TMwcXIxCqqNtw6yTo5dj3sJ5yltxvML7u4azUGrXQoD0ku5r ZWg2x6bKNfE+4NW72FFIqmOfx/hLk/odEYXjJbm3csMR6jhHbsPrxHM7nxJDii4D9iAg 7SWg== MIME-Version: 1.0 X-Received: by 10.52.167.132 with SMTP id zo4mr3496vdb.97.1401785855820; Tue, 03 Jun 2014 01:57:35 -0700 (PDT) In-Reply-To: References: Date: Tue, 3 Jun 2014 18:57:35 +1000 Subject: Re: Automating windows media player on win7 From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401785863 news.xs4all.nl 2955 [2001:888:2000:d::a6]:49691 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72493 On Tue, Jun 3, 2014 at 6:10 PM, Deogratius Musiige wrote: > Hi guys, > > > > I have been fighting with automating wmplayer but with no success. > > It looks to me that using the .OCX would be the best option. I found the > code below on the net but I cannot get it to work. > > I can see from device manager that a driver is started by I get no audio > out. > > What am I doing wrong guys? > > > > # this program will play MP3, WMA, MID, WAV files via the WindowsMediaPlayer > > from win32com.client import Dispatch > > mp = Dispatch("WMPlayer.OCX") > > tune = mp.newMedia("./plays.wav") > > mp.currentPlaylist.appendItem(tune) > > mp.controls.play() > > raw_input("Press Enter to stop playing") > > mp.controls.stop() > > > > Br > > Deo First suggestion: post plain text to this list, not HTML. You don't need it to look like the above. :) Secondly: Is there a particular reason that you need to be automating Windows Media Player specifically? I have a similar project which works by sending keystrokes, which means it works with anything that reacts to keys; mainly, I use it with VLC. It can invoke a movie or audio file, can terminate the process, and can send a variety of commands via keys. It's designed to be used on a (trusted) LAN. Code is here: https://github.com/Rosuav/Yosemite Once something's invoked by the Yosemite project, it simply runs as normal inside VLC. Easy to debug audio problems, because they're managed the exact same way. Granted, this does assume that it's given full control of the screen (it's designed to manage full-screen video playback; in fact, my siblings are right now watching Toy Story 3 in the other room, using an old laptop driving a TV via S-Video, all managed via the above project), so it may not be ideal for background music on a computer you use for other things; but feel free to borrow ideas and/or code from there. (And for what it's worth, I use this as one of my sources of BGM when I'm coding - just let it invoke the file, then manually flip focus back to what I'm doing.) ChrisA