PDA

View Full Version : Music API?



brturn
2004-04-30, 05:46 PM
What is the API to the music/sound library in GB-PVR? Do modules have access to the current playlist, etc?

I'm interested in writing a party-mode jukebox module, but don't want to re-write all the code that is already being used by the music module.

Thanks,
--Bryan

sub
2004-04-30, 05:59 PM
The plugin API allows you specify a list of songs for playback, and also allows you force playback of a specific song. Normal GB-PVR functionality allows you to skip forward or back a track and pause/play/stop.

If you'd need specific APIs to be available other than these, just let me know what you need and I'll add them.

brturn
2004-04-30, 06:31 PM
Sub,

Thanks for the response. Where is the list of APIs? I downloaded the WeatherPlugin and GB-PVR, but could not find the C++/C# API files. I have also looked through the documentation and the forums, but alas, no *.h files..?

I'm sure I'm missing the obvious doc or *.cs file..

Thanks,
--Bryan

sub
2004-04-30, 06:36 PM
Support for plugins has only been in GB-PVR a few weeks, and I've not yet written any documentation to describe the API. The weather plugin gives a reasonable over of how you create a plugin. It only uses a couple of methods on the plugin helper, but here are the others:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">using System.Xml;

namespace GBPVR.Public
{
/// &#60;summary&#62;
/// IPluginHelper exposes useful functions that can be used by the plugins.
/// To use call&#58; PluginHelperFactory.getPluginHelper&#40;&#41;.ReturnToMain Menu&#40;&#41;
/// &#60;/summary&#62;
public interface IPluginHelper
{
void ReturnToMainMenu&#40;&#41;;

string GetSkinRootDirectory&#40;&#41;;

string GetInstallDirectory&#40;&#41;;

string getStandardSkinDirectory&#40;&#41;;

Image getSkinImage&#40;string imageName, string skinSubDirectory&#41;;

XmlDocument GetConfiguration&#40;&#41;;

void PlayVideoFile&#40;String filename&#41;;

void PlayAudioFile&#40;String filename&#41;;

void PlayAudioFiles&#40;Queue files&#41;;
}
}
[/QUOTE]

sub
2004-04-30, 06:38 PM
http://gbpvr.com/cgi-bin/ikonboard.cgi?act=ST;f=4;t=1 contains a description of the interface that must be implemented by plugins.

brturn
2004-04-30, 06:55 PM
Aha&#33; That&#39;s what I was looking for.. Thanks. I&#39;ll poke around at the interface and see if I can get something working.

Some more quick questions;

- Why is there a &#39;string&#39; and also a &#39;String&#39;, are these different classes?

- How does the music module display directories? Is that done &#39;by hand&#39; in the code, or is there a File &amp; Directory selection module API?

Off hand, a jukebox will need these additional interfaces:

// Append a track to the currently playing queue
AppendAudioFile(..)

// Query information about the currently playing track
GetCurrentlyPlayingInfo( out string filename, out ... position, ..more..? )

As well as some event which is sent to the task when the queue has finished playing.

Thanks.
--Bryan

sub
2004-05-01, 05:55 AM
I&#39;ve added methods to:
pluginHelper.AddAudioFileToQueue(string filename)
IList playList = pluginHelper.GetAudioPlayQueue(out currentlyPlayingIndex)

I&#39;ll also think about an approach to supply the additional info you mentioned.

2004-05-01, 04:45 PM
Sub,

It looks like there are two &quot;Bryans&quot; interested in additional audio related pluginHelper methods. It&#39;s probably too late to get anything else in release 17, but I thought I would at least mention a couple of new things.

1. Can you provide away to control the volume in the MVP. Either just up and down or set to a specific percentage level.

2. If a client was controlling a particular MVP and that MVP was put in &quot;Standby&quot;, could a task wake up the MVP out of &quot;Standby&quot;.

The other important one, that you already know about, is the ability to have the client return which MVP it is connected to.

Thanks,

Bryan B.

sub
2004-05-01, 06:03 PM
The next release also contains a method to determine the client type (Overlay/VMR/XCARD/MVP). In the case of the MVP, the MAC address is appended to this.

I dont have the ability to place the MVP in standby or wake it up.

2004-05-01, 07:11 PM
Good news on the MAC address.

Do you have away to change the volume?

Bryan

brturn
2004-05-03, 03:28 PM
Sub,

Thanks for those new APIs. What version will they be in?

I have a working &quot;hello world&quot; project now, based on the weather app source. It was pretty easy to get set up, and the graphics architecture allows a lot of freedom, which is nice since the Jukebox will need sub-menus as well.

Questions:
- How do you show the current play time on video? That is basically what I want to display for the currently playing track.

- Since you gave access to the playlist + index, I won&#39;t need an event to signal the end of the playlist (but still need the track time + length, or filename + position to display play time).

- What API are you using for directory browsing? Is there a standard in .NET for this?

- How do you extract the track information given a file name (ie: artist, album, genre, etc..)? Is there a .NET API for this also?

Thanks,
--Bryan

sub
2004-05-03, 05:02 PM
Hi brturn.

I was intending to do a release over last weekend, but I&#39;m pretty busy at work at the moment so it&#39;ll be a few more days.

I&#39;ve changed the method I added a couple of days ago to:

IList GetAudioPlayList(out int currentIndex, out int trackDuration, out int playbackPosition);

trackDuration and playbackPosition will return values in seconds.

sub
2004-05-03, 05:03 PM
I use the System.IO.Directory.GetFiles(...) method for find files in a directory. It also has static methods for gettings lists of directories.

sub
2004-05-03, 05:04 PM
I&#39;ve got a pretty small class that I use for extracting the ID3 tags from MP3 files. Email me if you want a copy.

brturn
2004-05-03, 05:08 PM
Sub,

Excellent, that set of APIs should give all the functionality I need for the Jukebox. ;)

Keep up the good work&#33;
--Bryan

brturn
2004-05-04, 03:22 PM
Sub,

There&#39;s another piece missing.. I need the Audio directory from the configuration file.

Is that available from the XML config interface, or would you rather expose it via the Helper class?

Thanks,
--Bryan

sub
2004-05-04, 08:00 PM
Just get that from the config. The setting isn&#39;t going to change.

tkgafs
2004-10-10, 09:35 PM
Quote[/b] (sub @ May 01 2004,19:03)]The next release also contains a method to determine the client type (Overlay/VMR/XCARD/MVP). In the case of the MVP, the MAC address is appended to this.

Are there any details on using this method ?

tkgafs

bryan
2004-10-10, 09:50 PM
If you use the function:

PluginHelperFactory.getPluginHelper().GetClientIde ntifier()

It will return a string containing:

MVP xxxxxxxxxxxx

where xxxxxxxxxxxxx is the MAC address of the MVP you are connected to.

tkgafs
2004-10-11, 12:28 AM
Sub,

in the jukebox plugin the following code is used
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
int currentIndex;
int trackDuration;
int playbackPosition;
System.Collections.IList PlayList = PluginHelperFactory.getPluginHelper&#40;&#41;.GetAudioPlay List&#40;out currentIndex, out trackDuration, out playbackPosition&#41;;


[/QUOTE]

this works fine if the plugin is running on the PC but does not work if the plugin is using an MVP as its client

is the method if thats the right terminology implemented on the MVP client ?

tkgafs

sub
2004-10-11, 01:08 AM
When the MVP is playing audio tracks, I dont know how long the track is, or where in the playback it&#39;s up to. I could probably write some code to parse the MP3 and determine the duration when I ask the MVP to start playing it, but I&#39;ll never be able to tell where abouts the playback is up to.

tkgafs
2004-10-11, 01:19 AM
Quote[/b] (sub @ Oct. 11 2004,02:08)]When the MVP is playing audio tracks, I dont know how long the track is, or where in the playback it&#39;s up to. I could probably write some code to parse the MP3 and determine the duration when I ask the MVP to start playing it, but I&#39;ll never be able to tell where abouts the playback is up to.
I see it is actually the MVP which is playing the mp3 you are simply supplying blocks of data for it to decode,

If you could write something to let a plugin on the mvp know the total length of an mp3 in seconds that would probably be useful, in the meantime I&#39;ll change the jukebox plugin so that it does not display the progress bar when it is on the MVP , as it looks kind of broken as it is

tkgafs

smelcher
2008-04-11, 04:56 PM
Sub,

I am adding/using synchronized lyrics to Psycik's MusicLibrary2 plugin. Everything works fine standalone but since I do not know the playback position on the MVP I cannot scroll the lyrics. I have read several posts and understand the fact that you do not know where the MVP is during playback. That being said, is there not a way that GBPVR can "guess" as to when the song has started playing? Basically, can you start a stopwatch every time you tell MVP to start playing a song. If the user stopped the song, obviously you would pause the timer. Likewise, if a new new song started, the stopwatch would go back to 00:00 and so forth.

I also noticed in another post that you do send en event as to when you send a new song to the MVP so I can also look at using this and creating my own stopwatch.

Thanks for the help

sub
2008-04-11, 05:01 PM
I am adding/using synchronized lyrics to Psycik's MusicLibrary2 plugin. Everything works fine standalone but since I do not know the playback position on the MVP I cannot scroll the lyrics. I have read several posts and understand the fact that you do not know where the MVP is during playback. That being said, is there not a way that GBPVR can "guess" as to when the song has started playing? Basically, can you start a stopwatch every time you tell MVP to start playing a song. If the user stopped the song, obviously you would pause the timer. Likewise, if a new new song started, the stopwatch would go back to 00:00 and so forth.Sorry, its unlikely this limitation will be removed in the near future. Based on the wildy varying bitrates of audio files, and the amount of buffering performed on the MVP/PCH, it'd be next to impossible to guess this with any accuracy using a timer.

ACTCMS
2008-04-11, 11:42 PM
I'm taking a hit with this too on a couple of things to do with the current audio playback position...
Sorry, its unlikely this limitation will be removed in the near future. Based on the wildy varying bitrates of audio files, and the amount of buffering performed on the MVP/PCH, it'd be next to impossible to guess this with any accuracy using a timer.I can see why you don't really want to spend time on this when you couldn't guarantee the accuracy of the result.

I don't really need "to the second" times, so I'll put my own clock in. The obvious place where this falls down though is when the user pauses the audio stream. Would it be possible to add EventTypes AudioPause and AudioResume to Notify(...) ?