Okay heres my problem, the fastforward and its opposite don't work correctly. I want the user to be able to enter X seconds to ff or go back, but since its a COM and it doesn't provide this function (I think its meant for WPF or WF where you just hold the button as long as you want to ff or go back), is there anyway I can implement this myself.

ANYWAYS.... Heres my code. Feel free to use it as your own if you want.
If you do make sure to reference to Itunes type class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTunesLib;
namespace itunes_try
{
    class Itunes
    {
        public Itunes(iTunesApp Instance)
        {
            App = Instance;
        }

        iTunesApp App;

        public void Command(string Command, string File = " ")
        {
            Command.ToLower();
            switch (Command)
            {
                case "playfile":
                    App.PlayFile(File);
                    break;
                case "play":
                    App.Play();
                    break;
                case "stop":
                    App.Stop();
                    break;
                case "next":
                    App.NextTrack();
                    break;
                case "back":
                    App.PreviousTrack();
                    break;
                case "fastforward":
                    App.FastForward();
                    break;
                case "fastbackward":
                    App.BackTrack();
                    break;
                case "quit":
                    App.Quit();
                    break;
                case "pause":
                    App.Pause();
                    break;
                case "getname":
                    Console.WriteLine(App.CurrentStreamTitle);
                    break;
                default:
                    Console.WriteLine("Please enter one of the following commands: PlayFile, Play, Pause, "+
                        "Quit, FastForward, FastBackward, Next, Back, Stop");
                    break;
            }

        }

    }
}

Dani AI

Generated

: Fast-forward and rewind on the iTunes COM object are control commands (they start a FF/rewind action) and are not meant to jump the play head by an arbitrary number of seconds. The COM interface exposes a PlayerPosition property (position in seconds) that can be read and set; using that property is the reliable way to implement “skip forward/back X seconds.” (documentation.help)

A minimal, safe pattern (C#) is to read the current position, compute the target, clamp it to the track length, then set PlayerPosition. For example:

public void SeekRelative(int seconds)
{
    if (App == null) return;
    var track = App.CurrentTrack;
    if (track == null) return;

    int cur = App.PlayerPosition;
    int dur = track.Duration;
    int newPos = Math.Max(0, Math.Min(cur + seconds, dur));
    App.PlayerPosition = newPos;
}

This uses the iTunes COM PlayerPosition and the track Duration to avoid seeking outside the track. The PlayerPosition setter will clamp out-of-range values and will fail if no track is loaded/playing, so check CurrentTrack/PlayerState and wrap the call in try/catch for robustness. (documentation.help)

: “reference” here means adding the iTunes COM type library to the project (Project → Add Reference → COM → “iTunes x.x Type Library”), which makes the iTunesLib namespace available. If Visual Studio complains about embedding the interop type, set the reference property Embed Interop Types = False (or instantiate via the interface) to resolve it. (peschuster.de)

Notes and troubleshooting: some platform bindings expose player position as a double (macOS scripting/bridge differences), so if compilation/marshal errors occur consider casting or using dynamic. Always validate CurrentTrack and PlayerState before setting PlayerPosition and handle exceptions from the COM call. (stackoverflow.com)

I do not understand what is meant by the reference

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.