write a flash player by python

Thread Solved

Join Date: Dec 2006
Posts: 4
Reputation: seasou is an unknown quantity at this point 
Solved Threads: 0
seasou seasou is offline Offline
Newbie Poster

write a flash player by python

 
0
  #1
Dec 15th, 2006
I want to write a flash player by using python,can someone help me .

Thanks a lot.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,983
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 926
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: write a flash player by python

 
0
  #2
Dec 15th, 2006
I am not sure if there is a Python module out there that includes the .swf file format. However you can press your webbrowser into service ...
  1. import webbrowser
  2.  
  3. # html code to embed a .swf flash file player
  4. str1 = """
  5. <html>
  6. <head>
  7. <title>Embedded SWF Player</title>
  8. </head>
  9. <body onLoad="resizeTo(560, 500);">
  10. <!-- you can put your own .swf movie file here -->
  11. <embed src = "Chickens.swf" width="500" height="350"
  12. hidden=false autostart=true loop=1>
  13. </body>
  14. </html>
  15. """
  16.  
  17. # write the html file to the working folder
  18. fout = open("EmbeddedFlash.htm", "w")
  19. fout.write(str1)
  20. fout.close()
  21.  
  22. # now open your web browser to run the file
  23. webbrowser.open("EmbeddedFlash.htm")
The sample Chicken.swf file is in the attached zip.
Attached Files
File Type: zip EmbeddedFlash.zip (9.6 KB, 30 views)
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 4
Reputation: seasou is an unknown quantity at this point 
Solved Threads: 0
seasou seasou is offline Offline
Newbie Poster

Re: write a flash player by python

 
0
  #3
Dec 16th, 2006
hi vegaseat ,

thanks,it works,but I want that in my UI,
Do you know how to use the webbrowser module into a canvas.
any way thank you so much!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,523
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 169
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: write a flash player by python

 
0
  #4
Dec 17th, 2006
Actually the Python25 version of wxPython has a flash player component. Here is the demo they give:
  1. import os
  2. import wx
  3.  
  4. if wx.Platform == '__WXMSW__':
  5. from wx.lib.flashwin import FlashWindow
  6.  
  7. from Main import opj
  8.  
  9. #----------------------------------------------------------------------
  10.  
  11. class TestPanel(wx.Panel):
  12. def __init__(self, parent, log):
  13. wx.Panel.__init__(self, parent, -1)
  14. self.pdf = None
  15.  
  16. sizer = wx.BoxSizer(wx.VERTICAL)
  17. btnSizer = wx.BoxSizer(wx.HORIZONTAL)
  18.  
  19. self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)
  20. self.flash.LoadMovie(0, 'file://' + os.path.abspath('data/Asteroid_blaster.swf'))
  21.  
  22. sizer.Add(self.flash, proportion=1, flag=wx.EXPAND)
  23.  
  24. btn = wx.Button(self, wx.NewId(), "Open Flash File")
  25. self.Bind(wx.EVT_BUTTON, self.OnOpenFileButton, btn)
  26. btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
  27.  
  28. btn = wx.Button(self, wx.NewId(), "Open Flash URL")
  29. self.Bind(wx.EVT_BUTTON, self.OnOpenURLButton, btn)
  30. btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
  31.  
  32. btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
  33. sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
  34.  
  35. self.SetSizer(sizer)
  36. self.SetAutoLayout(True)
  37.  
  38.  
  39.  
  40. def OnOpenFileButton(self, event):
  41. dlg = wx.FileDialog(self, wildcard="*.swf")
  42.  
  43. if dlg.ShowModal() == wx.ID_OK:
  44. wx.BeginBusyCursor()
  45. self.flash.LoadMovie(0, 'file://' + dlg.GetPath())
  46. wx.EndBusyCursor()
  47.  
  48. dlg.Destroy()
  49.  
  50.  
  51. def OnOpenURLButton(self, event):
  52. dlg = wx.TextEntryDialog(self, "Enter a URL of a .swf file", "Enter URL")
  53.  
  54. if dlg.ShowModal() == wx.ID_OK:
  55. wx.BeginBusyCursor()
  56. # setting the movie property works too
  57. self.flash.movie = dlg.GetValue()
  58. wx.EndBusyCursor()
  59.  
  60. dlg.Destroy()
  61.  
  62.  
  63.  
  64. #----------------------------------------------------------------------
  65.  
  66. def runTest(frame, nb, log):
  67. if wx.Platform == '__WXMSW__':
  68. win = TestPanel(nb, log)
  69. return win
  70. else:
  71. from Main import MessagePanel
  72. win = MessagePanel(nb, 'This demo only works on Microsoft Windows.',
  73. 'Sorry', wx.ICON_WARNING)
  74. return win
  75.  
  76.  
  77. overview = """\
  78. <html><body>
  79. <h2>wx.lib.flashwin.FlashWindow</h2>
  80.  
  81. The wx.lib.pdfwin.FlashWindow class is yet another example of using
  82. ActiveX controls from wxPython using the new wx.activex module. This
  83. allows you to use an ActiveX control as if it is a wx.Window, you can
  84. call its methods, set/get properties, and receive events from the
  85. ActiveX control in a very intuitive way.
  86.  
  87. <p> Using this class is simpler than ActiveXWrapper, doesn't rely on
  88. the win32all extensions, and is more "wx\'ish", meaning that it uses
  89. events and etc. as would be expected from any other wx window.
  90.  
  91. <p> This demo embeds the Shockwave Flash control, and lets you play a game.
  92.  
  93. </body></html>
  94. """
  95.  
  96. #----------------------------------------------------------------------
  97.  
  98.  
  99.  
  100. if __name__ == '__main__':
  101. import sys,os
  102. import run
  103. run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
  104.  
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 4
Reputation: seasou is an unknown quantity at this point 
Solved Threads: 0
seasou seasou is offline Offline
Newbie Poster

Re: write a flash player by python

 
0
  #5
Dec 18th, 2006
Hi,It can't work,the error info is below
Traceback (most recent call last):
File "F:\flashRobots\flashPlayer.py", line 7, in ?
from Main import opj
ImportError: No module named Main

thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 137
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: write a flash player by python

 
0
  #6
Dec 18th, 2006
I think wxPython demos were written by my C++ professor or his father. He always uses the C++ trick of putting in obscure header files, to make student's life harder!

I have simplified some code that works without those extra imports at:
http://www.daniweb.com/code/snippet615.html
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 4
Reputation: seasou is an unknown quantity at this point 
Solved Threads: 0
seasou seasou is offline Offline
Newbie Poster

Re: write a flash player by python

 
0
  #7
Dec 20th, 2006
Thanks,it's working.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC