Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 10th, 2005, 11:12 AM   #1
Gunman
Programmer
 
Gunman's Avatar
 
Join Date: Oct 2005
Posts: 56
Rep Power: 4 Gunman is on a distinguished road
Media Player

Hello. I was thinking of coding a media player as my first project and I would like to know some things like what processors I need and how do I go about using them. If anyone of you all know any websites that are relevant to my question, kindly post the link. Thanks in advance.
Gunman is offline   Reply With Quote
Old Dec 10th, 2005, 11:52 AM   #2
groovicus
Programmer
 
Join Date: Nov 2004
Posts: 84
Rep Power: 5 groovicus is on a distinguished road
I have a few other suggestions before you go about coding a media player.. maybe do a small program to see if you can determine if a file exists? Then maybe build on that to see that if a file exists, that you can open it and read it. Then maybe expand on that to see if you can find multiple files.

Are you planning on creating a command line interface, or Console? If you want to do a console app, then maybe a small project to see if you can create yourt own simple window. Then maybe a simple window with a few buttons that print messages. And then maybe a window that accepts a filename as input and then looks for it.

I think the first thing you might want to consider doing is sitting down with a pencil and paper and making a list of everything you want your media player to do. Then consider how each part has to fit together. Then work on small bits at a time. Otherwise you may find yourself a bit overwhelmed.
__________________
HijackThis Team-SFDC
groovicus is offline   Reply With Quote
Old Dec 10th, 2005, 11:56 AM   #3
Gunman
Programmer
 
Gunman's Avatar
 
Join Date: Oct 2005
Posts: 56
Rep Power: 4 Gunman is on a distinguished road
Sounds cool. Do you know of any site that teaches these stuff? Thanks.
Gunman is offline   Reply With Quote
Old Dec 10th, 2005, 12:08 PM   #4
Prm753
Professional Programmer
 
Prm753's Avatar
 
Join Date: Oct 2005
Location: United States
Posts: 447
Rep Power: 4 Prm753 is on a distinguished road
Send a message via AIM to Prm753 Send a message via MSN to Prm753
http://www.winprog.org/tutorial/

Try that for Win32 API
__________________
The world's first athletic computer geek!
The home of PrProgramsStudios
How not to post a question: <-- Please don't reply
Prm753 is offline   Reply With Quote
Old Dec 10th, 2005, 12:11 PM   #5
Master
Programmer
 
Master's Avatar
 
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4 Master is on a distinguished road
I made a window application that function just like media player in ruby. I basically used API such as MciSendString function from winm.dll. I believe in order to make one, you should have basic knowlegde of API calling. if you want to see the code for my audio in ruby. I could post it, it can simply be written in C++ too. Hope that helps
Master is offline   Reply With Quote
Old Dec 10th, 2005, 12:37 PM   #6
groovicus
Programmer
 
Join Date: Nov 2004
Posts: 84
Rep Power: 5 groovicus is on a distinguished road
I don't know of any sites right off, but there should by any number of sites that have sample code. You should really start with a pencil and paper first though.

For example, suppose I do tech support on a forum where I gat asked the same questions over and over again. Since I want to save time, I create my own canned responses and store them in a text file, but after awhile it gets so big that it is hard to find the ones I want. I decide to create my own app that alphabetizes responses in their own little seperate file. So now I am ready to determine what I need my program to do.

******

-open files
-save files
-edit files
-display a user interface
-find files
-display files

Now it comes down to making a few decisions. First of all, I have two related processes -Opening files and saving files. I also have two more that are sort of related. Editing files and finding files. So maybe the first decision needs to be, what kind of format do we want to use for saving files? Text files are simple. Do we need to maybe encrypt the files so that nobody sees our canned responses? Do we want to store them as individual files? Do we want to store them in one big text file and just load the entire range of responses into memory each time we use the program? How do we want to arrange them? Alphabetically? By use?

Then we need to make some decisions about the user interface. It should be quite obvious that a command line program probably won't be too efficient for this type of application. So we need to decide.. how do we want to be able to search for the responses that we want? Typing in a keyword would be nice. I would also like a drop downlist that once I choose a letter, I get another dropdown that lists the saved speeches within that category. I am also going to want a text area that displays the speech so that I can edit it. I would also like it to be able to save any changes I make.

Now we need to figure out what we need to do to make all the little parts that will do what we want. So starting out simply, we need to be able to open and save files. What library functions will help us do that? What happens if we try to load a file that doesn't exist? What do we want our application to do? Once we research that, we should be able to find some examples of what we want to do, and modify the code so that it fits our exact needs.

I decide that the easiest way to store all my responses is in one big text file. Since I need a way to distinguish between different responses, I decide that I will put a row of asterisks between each response. That means when I load my list of responses, somehow my application will have to sort them properly, as well as distinguish where the rows of asterisks are. Now my next test would be to see if I can read in a file of text and recognize when there is a row of asterisks. After I can do that, I would further modify it to somehow sort those responses.

Finally we can consider the gui. We know we want at least one dropdown menu, a text area, and some buttons that do different things, so our next step would be to see if we can create a window and add parts little by little until we get some sort of interface we can work with.

Once we get all of the seperate pieces doing what we want them to do, then we can start putting them together, little bit by little bit. That's where you need to start. Programming is more than just slapping some code together. It is almost always a series of steps, starting with defining each individual problem, and then solving each little problem. Then once your little problems are solved, they can all be put together to solve your bigger problem. In your case, your problem is "How do I create my own media player".

EDIT: I didn't mean to get long winded, I just wanted to point out that in you need some sort of a game plan before you even start. It doesn't do much good to say "Use the WIN32 API" if you don't even know why you need them. Once you know what you need, then you can go about finding it, or asking questions of people so that they can help you find what you need.
__________________
HijackThis Team-SFDC
groovicus is offline   Reply With Quote
Old Dec 10th, 2005, 12:38 PM   #7
Gunman
Programmer
 
Gunman's Avatar
 
Join Date: Oct 2005
Posts: 56
Rep Power: 4 Gunman is on a distinguished road
Master - Sure, I would like to see the code.
Prm753 - Thanks for the link!
Gunman is offline   Reply With Quote
Old Dec 10th, 2005, 12:53 PM   #8
Gunman
Programmer
 
Gunman's Avatar
 
Join Date: Oct 2005
Posts: 56
Rep Power: 4 Gunman is on a distinguished road
Wink Thanks

grrovicus, thanks for the guide! I used to wonder what others meant by saying this, "You should really start with a pencil and paper first though". You explained the whole thing and much more..=) A BIG THANKS AGAIN...=)
Gunman is offline   Reply With Quote
Old Dec 10th, 2005, 7:36 PM   #9
Master
Programmer
 
Master's Avatar
 
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4 Master is on a distinguished road
#==============================================================================
# ** Audio
#==============================================================================
class Audio
  WAV = Win32API.new('winmm.dll', 'PlaySoundA', 'pll', 'l') 
  MCIExecute = Win32API.new("winmm", "mciExecute", ["P"], "B")
  MCISendString = Win32API.new('winmm','mciSendString','%w(p,p,l,p)','V')
  GetDevCaps = Win32API.new('winmm', 'auxGetDevCapsA', %w(l p l), 'l')
  GetVolume = Win32API.new('winmm', 'auxGetVolume', %w(l p), 'l')
  SetVolume = Win32API.new('winmm', 'auxSetVolume', %w(l l), 'l')
  GetNumDev = Win32API.new('winmm', 'auxGetNumDevs', %w(), 'l')
  AC = [0, 0, 0, 0, 0, 0].pack("L*")
  Volume = [0, 0].pack("L*")
  DIR = "Audio"
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :filename
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(filename = nil)
    dir = Dir.entries(DIR)
    @filename = rand(100).to_s
    unless filename.nil?
      dir.each{|file| 
      if file.include?(filename)
        @filename = file
        break
      end}
      @filename = filename if filename.include?('.')
      audio_open(@filename)
      audio_play()
    end
  end
  #--------------------------------------------------------------------------
  # * Audio Open
  #--------------------------------------------------------------------------
  def audio_open(filename)
    MCISendString.call("open "+DIR+"/"+filename+" alias "+@filename,0,0,0)
  end
  #--------------------------------------------------------------------------
  # * Audio Play
  #--------------------------------------------------------------------------
  def audio_play(filename = @filename)
    MCISendString.call("play " +filename+" from 0",0,0,0)
  end
  #--------------------------------------------------------------------------
  # * Audio Stop
  #--------------------------------------------------------------------------
  def audio_stop(filename = @filename)
    MCISendString.call("stop " + filename,0,0,0)
  end
  #--------------------------------------------------------------------------
  # * Audio Close
  #--------------------------------------------------------------------------
  def audio_close(filename = @filename)
    MCISendString.call("close "+ filename,0,0,0) 
  end
  #--------------------------------------------------------------------------
  # * Audio Pause
  #--------------------------------------------------------------------------
  def audio_pause(filename = @filename)
    MCISendString.call("pause "+ filename,0,0,0) 
  end
  #--------------------------------------------------------------------------
  # * Audio Resume
  #--------------------------------------------------------------------------
  def audio_resume(filename = @filename)
    #MCISendString.call("resume "+ filename,0,0,0) 
    MCISendString.call("play " +filename+"",0,0,0)
  end
  #--------------------------------------------------------------------------
  # * Audio Repeat
  #--------------------------------------------------------------------------
  def audio_repeat(filename = @filename)
    MCISendString.call("repeat "+ filename,0,0,0) 
  end
  #--------------------------------------------------------------------------
  # * Audio Seek
  #--------------------------------------------------------------------------
  def audio_seek(seek,filename = @filename)
    MCISendString.call("seek "+ filename + " to "+seek.to_s,0,0,0) 
  end
  #--------------------------------------------------------------------------
  # * Audio Rewind
  #--------------------------------------------------------------------------
  def audio_rewind(filename = @filename)
    MCISendString.call("rewind "+ filename,0,0,0) 
  end
  #--------------------------------------------------------------------------
  # * Audio Playback
  #--------------------------------------------------------------------------
  def audio_playback(filename = @filename)
    if audio_status == "stop".split(//)
      audio_play
    end
  end
  #--------------------------------------------------------------------------
  # * Audio Status
  #--------------------------------------------------------------------------
  def audio_status(filename = @filename)
    status = " " * 255
    MCISendString.call("status "+@filename+" mode",status,255,0)
    true_status = status.unpack("aaaa")
    return true_status
  end
end

#==============================================================================
# ** Movie
#==============================================================================
class Movie
  FindWindow = Win32API.new('user32', 'FindWindow', %w(p p), 'l')
  MCISEND = Win32API.new('winmm','mciSendString','%w(p,p,l,l)','V')
  Message = Win32API.new('user32','SendMessage','%w(l,l,l,l)','V')
  SystemMetric = Win32API.new('user32','GetSystemMetrics','%w(l)','L')
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :hwnd
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(movie, window = nil)
    @filename = Dir.entries("Movies")
    for i in 0...@filename.size
      if @filename[i].include?(movie)
        name = @filename[i]
        break
      end
    end
    @movie_name = "Movies/"+name
    @window = window
    main
  end
  #--------------------------------------------------------------------------
  # * Main
  #--------------------------------------------------------------------------
  def main
    @hwnd = FindWindow.call(nil,@window)
    MCISEND.call("open \""+@movie_name+"\" alias FILE style 1073741824 parent " + @hwnd.to_s,0,0,0)
    width = SystemMetric.call(0)
    if @width == 640
      Graphic.update
      sleep(1)
      Graphic.update
      sleep(1)
      Graphic.update
      sleep(1)
    end
    status = " " * 255
    MCISEND.call("play FILE",0,0,0)
    loop do
      sleep(0.1)
      Message.call(@hwnd.to_i,11,0,0)
      Message.call(@hwnd.to_i,11,1,0)
      MCISEND.call("status FILE mode",status,255,0)
      true_status = status.unpack("aaaa")
      break if true_status == "stop".split(//)
    end
    MCISEND.call("close FILE",0,0,0)
  end
end
the code contain a class for audio and movie, hope it helps
Master is offline   Reply With Quote
Old Dec 11th, 2005, 5:09 AM   #10
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
Quote:
Originally Posted by groovicus
Are you planning on creating a command line interface, or Console? If you want to do a console app, then maybe a small project to see if you can create yourt own simple window.
The console and command line are the same thing, no?
ivan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC