All Projects → harmonoid → libwinmedia

harmonoid / libwinmedia

Licence: MIT License
[Archived] A cross-platform simple media playback library for C/C++.

Programming Languages

C++
36643 projects - #6 most used programming language
dart
5743 projects
CMake
9771 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to libwinmedia

audio-metadata
A library for reading and, in the future, writing audio metadata. https://audio-metadata.readthedocs.io/
Stars: ✭ 41 (+17.14%)
Mutual labels:  mp3, flac, ogg, vorbis, opus, m4a
nipper
🌶 💽 Nipper - Youtube playlist (& video) ripper
Stars: ✭ 23 (-34.29%)
Mutual labels:  mp3, aac, ogg, vorbis, opus
loudgain
ReplayGain 2.0 loudness normalizer based on the EBU R128/ITU BS.1770 standard (-18 LUFS, FLAC, Ogg, MP2, MP3, MP4, M4A, AAC, ALAC, Opus, ASF, WMA, WAV, AIFF, WavPack, APE)
Stars: ✭ 127 (+262.86%)
Mutual labels:  mp3, aac, flac, opus, m4a
Youtube-DL-GUI
Graphical User Interace built around youtube-dl CLI
Stars: ✭ 38 (+8.57%)
Mutual labels:  mp3, aac, flac, opus
aplay-
a simple BitPerfect player
Stars: ✭ 23 (-34.29%)
Mutual labels:  mp3, aac, flac, m4a
slibs
Single file libraries for C/C++
Stars: ✭ 80 (+128.57%)
Mutual labels:  mp3, aac, flac, m4a
audio-tag-analyzer
Extracts metadata music metadata found in audio files
Stars: ✭ 18 (-48.57%)
Mutual labels:  mp3, flac, vorbis, m4a
Gogglesmm
Goggles Music Manager
Stars: ✭ 41 (+17.14%)
Mutual labels:  mp3, aac, audio-player, flac
uos
United Open-libraries of Sound. United procedures for open-source audio libraries. For FPC/Lazarus/fpGUI/MSEgui.
Stars: ✭ 112 (+220%)
Mutual labels:  mp3, flac, ogg, opus
sox.js
📢 NodeJS wrapper for the SoX audio tool
Stars: ✭ 18 (-48.57%)
Mutual labels:  mp3, flac, ogg
java-stream-player
🌌Java Advanced Audio Controller Library (WAV, AU, AIFF, MP3, OGG VORBIS, FLAC, MONKEY's AUDIO and SPEEX audio formats )
Stars: ✭ 112 (+220%)
Mutual labels:  mp3, flac, ogg
record-encode-audio-from-browser
Record/Encode Audio on Browser using the WebAudio API and "ported" libraries.
Stars: ✭ 55 (+57.14%)
Mutual labels:  mp3, flac, ogg
Symphonia
Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Stars: ✭ 191 (+445.71%)
Mutual labels:  mp3, aac, flac
Atldotnet
Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
Stars: ✭ 180 (+414.29%)
Mutual labels:  mp3, aac, flac
Audio Steganography Algorithms
A Library of Audio Steganography & Watermarking Algorithms
Stars: ✭ 146 (+317.14%)
Mutual labels:  mp3, aac, flac
Mediafile
A unified reader of metadata from audio & video files.
Stars: ✭ 138 (+294.29%)
Mutual labels:  mp3, aac, flac
Flacon
Audio File Encoder. Extracts audio tracks from an audio CD image to separate tracks.
Stars: ✭ 252 (+620%)
Mutual labels:  mp3, aac, flac
acxi
acxi is an audio conversion tool that helps sync lossless to lossy formats.
Stars: ✭ 35 (+0%)
Mutual labels:  mp3, flac, opus
y2mp3
An Electron app to download youtube playlist
Stars: ✭ 118 (+237.14%)
Mutual labels:  mp3, ogg, m4a
Av Converter
[av-converter.com] Audio and Video Converter, and YouTube downloader. Convert to MP3, MP4, AAC, FLAC, AC3, WAV, etc.
Stars: ✭ 97 (+177.14%)
Mutual labels:  mp3, aac, flac

libwinmedia

A cross-platform media playback library for C/C++ & Flutter with good number of features.

⚠️ Deprecated

The project is now archived. Reasons are documented below:

  • Inefficient Linux support: I had few (personal) reasons because of which my media URIs were not playing in GStreamer, so I decided to summon a WebKit instance using webview.h to make a basic JS interop setup for using WebAudio API (which itself is based on GStreamer in WebKitGTK). A good advantage that Flutter provides over other electron.js like alternatives is that it doesn't start a webview instance / JavaScript runtime, but using this plugin puts Flutter's those advantages to no use. This also makes us unable to add various crucial features like audio device selection/enumeration or equalizer etc. in future because of limited set of WebAudio APIs.
  • Unnecessary abstraction: As I said Linux support is not worth using, it puts Windows implementation to no use aswell. The WinRT APIs that this library exposes in a C like interface can be used directly in the project because they're already very user friendly & easy to integrate. Using this library on Windows just adds another layer of abstraction.
  • Unsafe: Using library on certain language/locales will cause crashes, since it heavily uses std::stof and std::stoi when doing JS interop. It is both inefficient and unsafe.
  • No backward compatibility: The library is only usable on later Windows 10 versions or higher. A project targetting a very small market share isn't worth maintaining.
  • No embedded Linux support: The library cannot be used on non-GTK Flutter embedders like flutter-pi etc. A lot of questions/issues have been made about this & it is not possible unless one decides to rewrite Linux implementation.

The project was started as an internal Harmonoid dependency to provide Windows/Linux support for the time-being, while I was looking for other libraries to settle on. Now that it is no longer used & current implementation isn't good enough, I don't see any point in adding features, fixing bugs etc. Thus, I have decided to discontinue this project. You are free to fork the project or use the code as allowed by the MIT license (which can be found in the LICENSE file).

Thankyou.

Example

A very simple example can be as follows.

C++

#include "libwinmedia/libwinmedia.hpp"

int32_t main(int32_t ac, const char** av) {
  using namespace std; 
  using namespace lwm;
  if (ac < 2) {
    cout << "No URI provided.\n"
         << "Example Usage:\n" << av[0]
         << " file://C:/alexmercerind/music.mp3\n" << av[0]
         << " https://alexmercerind.github.io/video.mp4\n";
    return EXIT_FAILURE;
  }
  auto player = Player(0);
  auto media = Media(av[1]);
  player.Open(vector<Media>{media});
  player.Play();
  player.events()->Position([](int32_t position) -> void {
    cout << "Current playback position is " << position << " ms.\n";
  });
  cin.get();
  return EXIT_SUCCESS;
}

Flutter

More about Flutter here or on the pub.dev.

dependencies:
  ...
  libwinmedia: ^0.0.1
import 'package:libwinmedia/libwinmedia.dart';

void main() {
  LWM.initialize();
  runApp(MyApp());
}

void demo() {
  var player = Player(id: 0);
  player.streams.medias.listen((List<Media> medias) {});
  player.streams.isPlaying.listen((bool isPlaying) {});
  player.streams.isBuffering.listen((bool isBuffering) {});
  player.streams.isCompleted.listen((bool isCompleted) {});
  player.streams.position.listen((Duration position) {});
  player.streams.duration.listen((Duration duration) {});
  player.streams.index.listen((int index) {});
  player.open([
    Media(uri: 'https://www.example.com/media/music.mp3'),
    Media(uri: 'file://C:/documents/video.mp4'),
  ]);
  player.play();
  player.seek(Duration(seconds: 20));
  player.nativeControls.update(
    album: 'Fine Line',
    albumArtist: 'Harry Styles',
    trackCount: 12,
    artist: 'Harry Styles',
    title: 'Lights Up',
    trackNumber: 1,
    thumbnail: File('album_art.png'),
  );
}

Bindings

  • just_audio: Cross platform audio playback library for Flutter, working on Android, iOS, macOS, Windows, Linux & Web.
  • libwinmedia-py: libwinmedia bindings for Python.
  • libwinmedia.dart: libwinmedia bindings for Flutter.

Support

Consider supporting the project by starring the repository or buying me a coffee.

Thanks a lot for your support.

Documentation

Setup

For using the library on Windows, you can download the pre-compiled shared library from the releases page & headers can be found here.

Usage

Create a new player.

Player player = Player(0);

Create a media to open inside player.

Media media = Media("file://C:/alexmercerind/music.mp3");
int32_t duration = media.duration();

Play the medias.

player.Open(std::vector<lwm::Media>{media});

Control playback.

player.Play();

player.Pause();

player.SetVolume(0.69);

player.SetRate(1.2);

player.Seek(10000);

player.SetIsLooping(false);

player.SetAudioBalance(1.0);

Listen to playback events.

player.events()->Position(
  [=](int position) -> void {}
);

player.events()->Duration(
  [=](int duration) -> void {}
);

player.events()->Rate(
  [=](float rate) -> void {}
);

player.events()->Volume(
  [=](float volume) -> void {}
);

player.events()->IsPlaying(
  [=](bool isPlaying) -> void {}
);

// Other events.

Create native system media controls.

Pass function as argument to receive event callbacks.

auto controls = lwm::NativeControls(
  [](auto button) -> void {
    if (button == NativeControlsButton::Play) std::cout << "Play clicked.\n";
    if (button == NativeControlsButton::Pause) std::cout << "Pause clicked.\n";
  }
);

Update the native system media controls.

controls.Update(
  std::make_shared<lwm::MusicNativeControlState>(
    "album_artist",
    "album",
    "track_count",
    "artist",
    "title",
    "track_number"
  ),
  "file://C:/Users/Hitesh/Pictures/AlbumArt.PNG"
);

Clear the native system media controls.

controls.Dispose();

Extract metadata tags.

auto tags = lwm::Tags::FromMusic(std::wstring(music_file));
std::wcout << "album        : " << tags.album() << ".\n"
           << "album_artist : " << tags.album_artist() << ".\n"
           << "bitrate      : " << tags.bitrate() << ".\n";
           
// Other metadata tags.

Extract album art.

lwm::Tags::ExtractThumbnail(
  music_file,
  TO_WIDESTRING(std::filesystem::current_path().string()),
  "ExtractedAlbumArt.PNG",
  lwm::ThumbnailMode::Music,
  400
);

Show video in a window.

For showing video, you must instantiate player as follows.

Player player = Player(0, true);

Control video output.

player.ShowWindow();

player.CloseWindow();

Notes

Windows

For showing video

You need to embed a manifest with maxversiontested property to the generated executable. The library creates a separate win32 window on another thread & uses XAML islands to render the MediaPlayerElement in it (for showing video). Learn more here & here.

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
            <maxversiontested Id="10.0.18362.0"/>
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
        </application>
    </compatibility>
</assembly>

Aim

The main goals of creating libwinmedia are:

  • Having high-level, user friendly library for media playback in C++.
  • Having small footprint, by using already existing OS APIs.
  • Having necessary things like network playback, event callbacks etc.
  • Being able to build similar high-level bindings to other programming languages, by just looking up for methods inside a single shared library.
  • Supporting multiple playback instances.
  • Supporting media tag-parsing & other things like lockscreen/system notifications.
  • Being permissively licensed.
  • Being cross-platform **.

** Currently only working on Windows & Linux.

License

Copyright (c) 2021 Hitesh Kumar Saini [email protected]

This library & work under this repository is MIT licensed.

Contributions welcomed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].