|
Posted by Klemens on 12/27/06 18:29
Dear Gilles,
that's more than I expected. Great! I'll try to build a WMP plugin from
this info.
Regards,
Klemens
Gilles Kohl schrieb:
> On 26 Dec 2006 23:34:56 -0800, "Klemens" <klemid@gmail.com> wrote:
>
> >I'm looking for a simple Windows-based MP3 player which allows me to
> >set bookmarks within my self-recorded MP3 audio books and jump directly
> >to them afterwards. Would also help if there is an API function for one
> >of the well-known players which I can use in self-written player shell.
>
> As I have an interest in audiobooks myself (most MP3 players and
> software do not handle their special requirements well) I gave this a
> quick whirl.
>
> Windows Media player should do the trick - it is not necessarily the
> simplest one around, but has the advantage of already being there in
> most cases.
>
> Media player can be embedded as an ActiveX control - I ignore what
> your programming language of choice is, but here are the steps to
> recreate the small "feasibility study" I did in C#/Visual Studio 2005.
> Any language/environment that supports ActiveX controls should work
> though.
>
> Create a new Windows Forms project.
>
> Right-click the toolbox and select "Choose Items ...", get yourself a
> cup of coffee, walk the dog, wash dishes,clean the house, and
> eventually return to your computer to see if the "Choose Toolbox
> Items" has finally finished exploring the registry. Switch to the "COM
> Components" tab, and check "Windows Media Player" (System32\wmp.dll).
> Click OK.
>
> Drag the media player icon (should appear under "General" in the
> toolbox) to your form.
>
> Add a button "Get Position" (buttonGetPosition), a button "Set
> Position" (buttonSetPosition), a button "Select Media"
> (buttonSelectMedia) a textbox (textBoxPosition), and an
> openFileDialog1.
>
> Replace the code for the form (Form1.cs) with the following:
>
> using System;
> using System.ComponentModel;
> using System.Windows.Forms;
>
> namespace Mp3PositionTest
> {
> public partial class Form1 : Form
> {
> public Form1()
> {
> InitializeComponent();
> }
>
> private void buttonSelectMedia_Click(object sender, EventArgs e)
> {
> openFileDialog1.CheckFileExists = true;
> openFileDialog1.DefaultExt = "mp3";
> if(openFileDialog1.ShowDialog() == DialogResult.OK)
> {
> axWindowsMediaPlayer1.URL = openFileDialog1.FileName;
> }
> }
>
> private void buttonGetPosition_Click(object sender, EventArgs e)
> {
> textBoxPosition.Text =
> axWindowsMediaPlayer1.Ctlcontrols.currentPosition.ToString();
> }
>
> private void buttonSetPosition_Click(object sender, EventArgs e)
> {
> axWindowsMediaPlayer1.Ctlcontrols.currentPosition =
> Double.Parse(textBoxPosition.Text);
> }
> }
> }
>
> The sample lets you select an MP3 file to play (it uses the
> openFileDialog for this), the thing to retain is that you have to
> assign a filename with path to the URL property.
>
> When you click "Get Position" the current position
> (axWindowsMediaPlayer1.Ctlcontrols.currentPosition) is retrieved (as a
> double) and displayed as a string in the textbox.
>
> Conversely, when you click "Set Position", the textbox contents is
> converted back to a double (make sure it can be, there is no error
> handling for the sake of clarity here) and assigned to the
> currentPosition property.
>
> That's it - this should get you started with your own bookmark
> handling.
>
> Regards,
> Gilles [MVP].
[Back to original message]
|