Tutorials/MP3Terminal/Page1

From NeoAxis Engine Wiki

Jump to: navigation, search

Media Player Terminal: Introduction

Introduction

In this series we are going to create a terminal that has the ability to play mp3 music files from anywhere on your computer. To get this job done, we are going to use a great audio library called Bass and the .NET wrapper library called Bass.NET.

By the end of the series I hope to show you how to create a fully fledged media player that can be accessed via a terminal. The functionality I hope to include consists of:

  • Volume control
  • Playlist
  • Play/Pause, Stop, Forward, Back buttons
  • Time display
  • ID3 Tag info display
  • Graphic equalizer
  • Digital Signal Processing (DSP) effects

The reason why i say 'hope to' though is that i am developing this as i write the tutorials, and while all this functionality is available in the library, we may not be able to implement it all through our terminal. But we will try.

This tutorial will also introduce you to (among other things):

  • Bass.NET (of course)
  • GUI creation
  • Config file creation
  • Reading configs using Engine.Utils.TextBlock
  • The logic editor

There are some things to know about this that may be a good or bad thing depending on how you look at it. Firstly the volume of your music is independent of the NeoAxis music and/or effects volume. That is why we will be making a volume control and i will show you how to use the music volume setting for NeoAxis to control the volume of your music. Secondly, music you play will not stop when we change map (or shouldn't if my thinking is correct). So i will show you how to stop the music at any point and leave it to you to do it if you want

Next up, we get Bass.NET and install it

Getting Bass.NET

Bass is created by Un4seen Developments. Through their hard work and the work of the community they have created Bass, as well as a handful of plugins that can be used to play and encode other files types. Bass can handle the playback of the following types:

  • MP3
  • MP2
  • MP1
  • OGG
  • WAV
  • AIFF

Through the freely available plugins, we can also support (among others):

  • WMA
  • ALAC
  • FLAC
  • AAC
  • AC3
  • APE

So you really have the potential to support all the major music formats, or as little as you like. In this tutorial, we won't be using any of the plugins, so we will have access to the first list files, but will concentrate on mp3 files. Using the plugins is quite simple, and i will leave that as a homework exercise.

For you convenience i had included direct download links to the files you need, but it is worthwhile to visit the site as it has a very helpful community and the software is being updated regularly

The Bass library comes as a single dll file, with libs and headers for delphi, C++, etc. we only need to copy Bass.dll from the zip file to our NeoAxis bin directory. No need for the documentation either, unless you want the original C++ docs for the library.

Bass.NET comes as an installer, which (depending on the install options you select) will register Bass.NET as a .NET assembly and integrate the help into the Visual Studio help. These two options are very handy, so please do it.

The install options that will make your life easier when using Bass.NET

Further on, you will see a button to register. Relax, the registration is free for non-commericial use and we will get a license key that will prevent an annoying nag screen from popping up. All you need is your name and an email and the key will be sent to you, easy as.

OK, so now that we have Bass.dll in your NeoAxis bin directory and Bass.NET installed, all we need to do is add a Bass.NET reference to our GameEntities.dll. If you selected to register Bass.NET as a .NET component, you simply select 'Add Reference -> .NET -> Bass.NET API for .NET 2.0' if not, you need to browse to the install directory and add it manually.

By now we should be ready to start with some code. The next section will get a basic C# class and gui written, so we can test it out in game and make sure we have everything in order.

Personal tools