Stefano Mtangoo 455 Senior Poster

We're here to help. Just post the code that you've already written and we'll be glad to fix any bugs or suggest ways to improve it.

+1 jlm699

I think also if you don't have idea where to start, one can help that but not writing the whole program for you!

Hope you will understand

Stefano Mtangoo 455 Senior Poster

Nope. Its wierd. Maybe its some sort of vista incompatibility

No! I have vista too and things are running smooth! Just run as admin and thing should be sorted

Stefano Mtangoo 455 Senior Poster

Ok After finding a DLL that can be having simple functions, I found Bass.DLL, and here is sample method for Loading Audio files. Can someone give me a start. I cannot find the ctypes variable equivalent of BOOL, QWORD etc. And also how to form a python function from this C/C++ code??

""" Loads a WAV, AIFF, MP3, MP2, MP1, OGG or plugin supported sample.
     HSAMPLE BASS_SampleLoad(
     BOOL mem,
         void *file,
         QWORD offset,
         DWORD length,
         DWORD max,
         DWORD flags
     );  """
            
    Bass_Load = ct.CFUNCTYPE(ct.DEFAULT_MODE) #Load function
Stefano Mtangoo 455 Senior Poster

try pinging instead of telneting and post result
example: ping www.yahoo.co.uk -t

Stefano Mtangoo 455 Senior Poster

After Long time searching I found nothig as such.
Then I tried to catch EVT_MEDIA_FINISHED by bind as shown belo

self.Bind(wx.media.EVT_MEDIA_FINISHED, self.onFinished_playing)

And the function below for modifying filename and call play

def onCheck_loop(self, path): #Loads file and calls play function
        self.path = path.strip()            
        if not self.player.Load(path):
            wx.MessageBox("Unable to Play this file, it is in the wrong format")
        else:
            self.SetTitle("Now Playing %s" %(self.path,))
            time.sleep(10)
            self.onPlay(wx.media.EVT_MEDIA_LOADED)
      
    def onFinished_playing(self, evt): 
            print "Finished, starting next track"
            time.sleep(10)
            self.onSetPath_loop()       #detects finished song and calls another function to Load file     
    #play it
    def onPlay(self, evt):  
        self.player.Play()              
        self.slider.SetRange(0, self.player.Length())
        self.player.SetVolume(0.404459081855)
Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

Basic example with for loop

#URL LIBRARY
from urllib2 import *
ur = urlopen("http://www.daniweb.com/forums/thread161312.html")#open url
contents = ur.readlines()#readlines from url file
fo = open("test.txt", "w")#open test.txt
for line in contents: 
    print "writing %s to a file" %(line,)
    fo.write(i)#write lines from url file to text file
fo.close()#close text file
Stefano Mtangoo 455 Senior Poster

I want to wait the song to finish after it finishes, I want to call another function
How do I do that in wxpython

Stefano Mtangoo 455 Senior Poster

Hello Developers,
I have simple media player that have slider that runs in sync with the song. When I want to move a song on given position using slider it moves slowly with strange gagging sound while other media player like foo/win' media player when you move song to a position it moves there instantly. How dod you do that with wx.Media??

def onPlay(self, evt): 
        self.player.Play()              
        self.slider.SetRange(0, self.player.Length())
        self.player.SetVolume(0.404459081855)
        volume = str(self.player.GetVolume())
        self.label.SetLabel("Vol: %s" %(volume,))
Stefano Mtangoo 455 Senior Poster

I already solved parent problem, and this automatically solved

Stefano Mtangoo 455 Senior Poster

I at last solved it!
I added event to ListCtrl when the track get selected it calls setpath which calls oncheck which Loads the file. I have left onplay only for playing files

Thanks all for your contributions, I really appreciate!
Bugfixing is very challenging!

Stefano Mtangoo 455 Senior Poster

on mine spybot makes it say "some settings are managed by your administrator"

It seems that you run with non-admin rights

Stefano Mtangoo 455 Senior Poster

I kno Bennet, Its is just funny to have IT/Developer and other guys here! lol:

Stefano Mtangoo 455 Senior Poster

I kno Bennet, Its is just funny to have IT/Developer and other guys here! lol:

Stefano Mtangoo 455 Senior Poster

Yes sir, but when tries to change homepage, it will politely ask you to confirm. Sir, it is very meek!

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

Are you using something like spybot search and destroy?

it locks your home page

Sir,
Spyboat is too gentle to lock the page, unless when it ask if you want to allow change and you commanded it "NO"

Stefano Mtangoo 455 Senior Poster

doesn't play file in my Machine!
Is something wrong with it?

Stefano Mtangoo 455 Senior Poster

I decided to roll back using system restore, and it worked!

Stefano Mtangoo 455 Senior Poster

Your own code? Can you post them? Have you noticed what is wrong??

Stefano Mtangoo 455 Senior Poster

can't see it in wxpy docs, any link or example?

Stefano Mtangoo 455 Senior Poster

The debug process never connected back to WINGIDE: Aborting debug session

I have tried repair python, no success. Also tried run IDLE same story

Stefano Mtangoo 455 Senior Poster

Yep Will take a look at that event!
Thanks Sir!

Stefano Mtangoo 455 Senior Poster

I think something might be wrong with Loading file and play it
Can someone explain how media ctrl loads file and plays it? May be from there I can find the bug and fix it!

Stefano Mtangoo 455 Senior Poster

I saw Bass.DLL but not google gave no tutorial for it, poor documentation and very heavy for newbie. Whooh! Is there simple DLL dealing with Multimedia (esp. Audio issues) that I can learn from?

Lame_enc is easily available but I have failed to use it, due to Lack of tutorials too! Help pls!

Stefano Mtangoo 455 Senior Poster

Anyone got it working? It gives message that now playing but no sound! what is wrong? Have tried on XP and Vista, and will try on ubuntu.

Stefano Mtangoo 455 Senior Poster

I didn't meant to convert you to Firefox browser, heeeh!

Stefano Mtangoo 455 Senior Poster

Thanks Marco. It is for learning purposes because I want to learn using Lame enc DLL. So what I want to do is get familiar with DLL that is simple before I get to that Lame DLL.

Anyway It is good option for practical purposes. BTW I'm Coding in Python, and there are few who deal with DLL. C/C++ guys are full equiped with DLL thing so I like to poster such thing here!

Thanks alot I will take look at Win32 API because there is python module for that! Heeeh

Stefano Mtangoo 455 Senior Poster

I need simple DLL to play audio file (at lest MP3). As simple as possible for me to use it in practicing playing with DLLs

Stefano Mtangoo 455 Senior Poster

I have attached the Icons. They are Tango Icons and are free to Download. Just extract to the folder with script following structure
folder\media_advanced.py
folder\icons

Stefano Mtangoo 455 Senior Poster

Everything seems to be well, but NOTHING GET PLAYED!!!! :oops:
I have tried and tried but doesn't work. WHAT IS WRONG???? :shock:

#media control
#Copyright  2008 Evstevemd
#Just media Player to play the playee
import wx
import wx.media as media
import os, sys

class MediaPlayer(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size = (600, 400))
        self.panel = wx.Panel(self, -1)
        #self.panel.SetBackgroundColour('grey')
        
        #Main Sizer
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        
        #Media Control
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.player = media.MediaCtrl(self.panel, -1, size = (400, 300))
        hbox.Add(self.player, 1, wx.EXPAND)
        #playlist and its Title in same sizer
        playlist_sizer = wx.BoxSizer(wx.VERTICAL)
        self.file_list = []
        #Playlist title
        self.playlist_title = wx.StaticText(self.panel, -1, "Current Play List", style = wx.ALIGN_CENTER)
        playlist_sizer.Add(self.playlist_title , 0, wx.EXPAND |wx.ALL, 5)
        #Play List display 
        self.playlist = wx.ListCtrl(self.panel, -1, size = (250, 300), style = wx.LC_REPORT)
        self.playlist.InsertColumn(col=0, heading = "Song Name", width = 150)
        self.playlist.InsertColumn(col=1, heading = "Directory", width = 100)
        self.playlist.InsertColumn(col=2, heading = "Artist", width = 175) 
        #operate
       

        playlist_sizer.Add(self.playlist , 1, wx.EXPAND |wx.LEFT|wx.RIGHT, 5)
        #Add them to a sizer
        hbox.Add(playlist_sizer, 1, wx.EXPAND)
        main_sizer.Add(hbox,1, wx.EXPAND)
        
        #Load widgets sizers & Bind to events
        hsizer1 = wx.BoxSizer()
        #open
        self.bopen = wx.Button(self.panel, -1, "Open File" )
        hsizer1.Add(self.bopen, 0, wx.ALL, 5)        
        self.Bind(wx.EVT_BUTTON, self.onLoad, id = self.bopen.GetId() )
        #stop
        self.bstop = wx.BitmapButton(self.panel, -1, wx.Bitmap("./icon/media-playback-stop.png"),size = (22, 22) )
        hsizer1.Add(self.bstop, 0, wx.LEFT|wx.TOP|wx.BOTTOM, 5)
        self.Bind(wx.EVT_BUTTON, self.onStop, id = self.bstop.GetId())
        #Play
        self.bplay = wx.BitmapButton(self.panel, -1,wx.Bitmap("./icon/media-playback-start.png"),size = (22, 22) )
        hsizer1.Add(self.bplay, 0,  wx.LEFT|wx.TOP|wx.BOTTOM, 5)
        self.Bind(wx.EVT_BUTTON, self.onPlay, id = self.bplay.GetId())
        #Pause
        self.bpause = wx.BitmapButton(self.panel, -1,wx.Bitmap("./icon/media-playback-pause.png"),size = (22, 22))
        hsizer1.Add(self.bpause, 0, wx.LEFT|wx.TOP|wx.BOTTOM, 5)
        self.Bind(wx.EVT_BUTTON, self.onPause, id …
Stefano Mtangoo 455 Senior Poster

Here is A little complex but good example (I don't know if it is right to copy here)
http://code.activestate.com/recipes/499341/
an someone explain it to a layman programmer level?
I can understand few but as I read it I got Lost in the world of codes

Help! Help! developers!

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

I was around the net and I found this Pymedia for python 2.5
So you enjoy it!
http://pymedia.org/downloads/pymedia-1.3.7.3.win32-py2.5.exe

Stefano Mtangoo 455 Senior Poster

Thanks for your contribution so far vega, it count alot!

Stefano Mtangoo 455 Senior Poster

I have been discussing with python guys and it seems as if I need help from C/C++ guys. Pse consider to visit the link and say anything you can say about the problem
Thanks

http://www.daniweb.com/forums/thread160430.html

Stefano Mtangoo 455 Senior Poster

No need for banging thing around with that anger. Why not try other browser when the one you have annoys you? In Mozilla every option is in your hand.

Stefano Mtangoo 455 Senior Poster

I read somewhere an article on ctypes and made life easier.
However, I still don't know where to use pointers and where to use other ctypes variables like c_char, c_int etc. Anyone to help?

Stefano Mtangoo 455 Senior Poster

I have simple player with wx.ListCtrl as playlist. I first Load List through open file dialog. I populate a dictionary with filenames (populated in Playlist) as keys with their path as values. When I press play, the onPlay method calls onSetPath method which looks up for selected file from list and Loads it path to wx.media.MediaCtrl and then it plays file.

The List Loads fine and onSetPath Loads the path but cannot play the file. Any correction on where I mess up?? Below is the code for mentioned method (Full code is little huge)

#Load File paths
    def onLoad(self, evt):
        dlg = wx.FileDialog(self, message = "Choose Media File to Open", defaultDir = os.getcwd(), defaultFile = "", wildcard = "Media Files|*.mp3;*.wma; *.avi; *.au;*.mpg", style = wx.FD_OPEN| wx.CHANGE_DIR |wx.FD_MULTIPLE)
        ret = dlg.ShowModal()
        if ret == wx.ID_OK:
            self.paths = dlg.GetPaths()
            self.onLoadPlaylist(self.paths)
            dlg.Destroy()
#Loads playList to the List box with name, Format, directory
    def onLoadPlaylist(self, paths):
        #get list of directories with file names eg c:\steve.mp3
        file_list_paths = paths 
        file_list = []
        file_path = dict() #hold filename_ext as keyword and path as value and can be compared to selected file in playlist and get its path as value
        for path in file_list_paths : 
            path.strip()
            directory, filename_and_ext = os.path.split(path)            
            full_tuple = (filename_and_ext, directory, "" )
            file_list.append(full_tuple)
            file_path[filename_and_ext] = path
            
        #Insert values in Col and Rows
        for i in file_list:
            index = self.playlist.InsertStringItem(sys.maxint, i[0])
            self.playlist.SetStringItem(index, 1, i[1])
            self.playlist.SetStringItem(index, 2, i[2])
        # Make dictionary the attribute of the class
        self.file_path = file_path
# Get …
Stefano Mtangoo 455 Senior Poster

Thanks vega, I see now how easy it can be. Can you give few words on how pointers to result and rguments work.
Thanks for brilliant example

Stefano Mtangoo 455 Senior Poster

I have Laptop with Vista Hom Business and Ubuntu. I cannot get Vista work with Rdesktop from XP Pro Desktop at work. Is there anyway to access Laptop with Ubuntu from XP Pro?

Why does My Vista's RDP doesn't work??

Best Regards

Stefano Mtangoo 455 Senior Poster

I have been trying to learn ctypes so as I can call C++ DLLs in python and have no problem on Loading DLLs. My question are: What are procedures of calling functions in DLLs especially since Py and C++ have different data types? I see argtypes and restypes: What are they?

Can someone provide very simple theoretical example from Loading DLL until releasing it? Here is my code for Loading the DLL :

import ctypes as ct
#load DLL
dll = ct.cdll.test_dll
print dll

result: <CDLL 'test_dll', handle 6eb40000 at 2914f30>

Stefano Mtangoo 455 Senior Poster
mypocket = ("gum", "wallet", "old kleenex", "bus ticket")
input_user = int (raw_input('How many item you need ? \n'))
for i in range(input_user):
    print mypocket[i], 
    #this will print from first to the limit of range
    #No catching of exceptions
    #use random module to randomize selection
Stefano Mtangoo 455 Senior Poster

Why Bother? I use firefox 3 and I enjoy, Consider it!
Anyway Bennet is good at MS things may be will help on this

Stefano Mtangoo 455 Senior Poster

Let me explain a little bit. I have Frame with media ctrl and Listctrl
The List of media files get Loaded in List ctrl and when user double clicks the file, It get played in the media player.

I have now failed to get file name (I plan to concatenate file name and directory) but even when I try to explicitly tell media control to play given file in List, it stays quiet!

Any suggestion on way to Go getting element
Here are some problematic functions

#Loads playList to the List box with name, Format, directory
    def onLoadPlaylist(self):
        file_list_paths = self.paths        
        self.file_list = []
        
        for path in file_list_paths : # Non original
            filename_and_ext, directory = os.path.split(path) 
            full_tuple = (path, directory, "")
            self.file_list.append(full_tuple) 
        #Insert values in Col and Rows
        
        #Insert values in Col and Rows
        for i in self.file_list:
            index = self.playlist.InsertStringItem(sys.maxint, i[0])
            self.playlist.SetStringItem(index, 1, i[1])
            self.playlist.SetStringItem(index, 2, i[2])
        
        
    # Get selected from list and set it path and reselect the next
    def onSetPath(self):
        index1 = self.playlist.GetFirstSelected() 
        filename = self.playlist.GetItemText(index1)     
        print filename
        self.path = filename

#play it
    def onPlay(self, evt):
        self.onSetPath()
        self.player.Play()
        self.slider.SetRange(0, self.player.Length())
        self.player.SetVolume(0.404459081855)
        volume = str(self.player.GetVolume())
        self.label.SetLabel("Vol: %s" %(volume,))
Stefano Mtangoo 455 Senior Poster

Sorry All,
I forgot to mention that it is wxpython.

Stefano Mtangoo 455 Senior Poster

I was playing with ListCtrl and I have only been able to get first value of the selected row. Is there any method I can use to get the rest of column's value in the selected row?
Help please
Steve

Stefano Mtangoo 455 Senior Poster

Is Gstreamer worth of looking at?

Stefano Mtangoo 455 Senior Poster

I found that Variables in Ctypes are different from python one. How do I interface the three variable; ctypes, C++ and python?

Thanks

Stefano Mtangoo 455 Senior Poster

Thanks Paul