[Banshee-List] Proposal: Mono.Media



Since the Banshee MediaEngine backend is being refactored soon to subsume libbanshee, I propose that this system be abstracted into a non-Banshee-specific library for audio/visual media: Mono.Media. The conspicuous absence of any media functionality in the Base Class Library* means that there is no unified .NET media framework between platforms: Windows developers usually call DirectShow through the .NET/COM bridge, Linux developers must roll their own solution (like Banshee), and so on. With an MIT licensed library which intelligently chooses a backend based on the platform, available components, and input file, any CLI program can easily provide rich media functionality. Here's is a rough outline for the library which I came up with in five minutes on the subway:

namespace Mono.Media {
    public class AudioPlayer
    public class AudioTranscoder
    public class VideoPlayer
    public class VideoTranscoder
    public enum VolumeScale {
        Linear,
        Logarithmic
    }
    ...
}

namespace Mono.Media.Backends {
    public interface IAudioPlayerBackend
    public interface IAudioTranscoderBackend
    public interface IVideoPlayerBackend
    public interface IVideoTranscoderBackend

    public class GstreamerBackend : IAudioPlayerBackend, IAudioTranscoderBackend, IVideoPlayerBackend, IVideoTranscoderBackend
    public class HelixBackend : IAudioPlayerBackend, IVideoPlayerBackend
    public class QuicktimeBackend : IAudioPlayerBackend, IAudioTranscoderBackend, IVideoPlayerBackend, IVideoTranscoderBackend
    public class DirectShowBackend : IAudioPlayerBackend, IVideoPlayerBackend
    ...
}

As an example, the AudioPlayer class might look a little like this:

public class AudioPlayer {
    public AudioPlayer()
    public AudioPlayer(IAudioPlayerBackend preferred_backend)
    public void Open(string uri)
    public bool TryOpen(string uri)
    public void Play()
    public void Pause()
    public void Close()
    public uint Position { get; set; }
    public double Volume { get; set; }
    public VolumeScale VolumeScale { get; set; }
    public IAudioPlayerBackend Backend { get; }
   
public IAudioPlayerBackend PreferredBackend { get; set; }
    public event EventHandler Played
    public event EventHandler Paused
    public event EventHandler Stopped
}

And an example use of the API might look like this:

AudioPlayer player = new AudioPlayer();
if(player.TryOpen("/home/scott/Music/still_alive.mp3")) {
    player.Play();
}

What do people think?

* While WPF (and by extension, Silverlight) has audio/visual capabilities, it does not have a full compliment of tools, such as transcoding. It also require the 3.5 framework.

--
Scott.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]