2012-08-09 09:45:04 +00:00
|
|
|
using System;
|
2012-01-16 20:08:38 +00:00
|
|
|
using System.IO;
|
2012-08-25 21:22:30 +00:00
|
|
|
using ANX.Framework.NonXNA;
|
|
|
|
using ANX.Framework.NonXNA.PlatformSystem;
|
2011-11-17 20:35:25 +00:00
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-11-17 20:35:25 +00:00
|
|
|
|
|
|
|
namespace ANX.Framework.Media
|
|
|
|
{
|
2012-01-16 20:08:38 +00:00
|
|
|
public sealed class MediaLibrary : IDisposable
|
2011-11-17 20:35:25 +00:00
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
private INativeMediaLibrary nativeLibrary;
|
|
|
|
|
2012-01-16 20:08:38 +00:00
|
|
|
#region Public
|
2012-08-25 21:22:30 +00:00
|
|
|
public MediaSource MediaSource
|
|
|
|
{
|
|
|
|
get;
|
|
|
|
private set;
|
|
|
|
}
|
|
|
|
|
2012-01-16 20:08:38 +00:00
|
|
|
public PictureCollection Pictures
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetPictures();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public PictureAlbum RootPictureAlbum
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetRootPictureAlbum();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public PictureCollection SavedPictures
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetSavedPictures();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public SongCollection Songs
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetSongs();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ArtistCollection Artists
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetArtists();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public AlbumCollection Albums
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetAlbums();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public PlaylistCollection Playlists
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetPlaylists();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public GenreCollection Genres
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetGenres();
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-25 21:22:30 +00:00
|
|
|
|
2012-01-16 20:08:38 +00:00
|
|
|
public bool IsDisposed
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
get;
|
|
|
|
private set;
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
public MediaLibrary()
|
|
|
|
{
|
2012-09-18 05:53:08 +00:00
|
|
|
nativeLibrary = PlatformSystem.Instance.CreateMediaPlayer();
|
2012-08-26 10:31:54 +00:00
|
|
|
MediaSource = MediaSource.GetAvailableMediaSources()[0];
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public MediaLibrary(MediaSource setSource)
|
|
|
|
{
|
2012-09-18 05:53:08 +00:00
|
|
|
nativeLibrary = PlatformSystem.Instance.CreateMediaPlayer();
|
2012-08-25 21:22:30 +00:00
|
|
|
MediaSource = setSource;
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~MediaLibrary()
|
|
|
|
{
|
|
|
|
Dispose();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Dispose
|
|
|
|
public void Dispose()
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
if (IsDisposed == false)
|
|
|
|
{
|
|
|
|
IsDisposed = true;
|
|
|
|
|
|
|
|
nativeLibrary.Dispose();
|
|
|
|
nativeLibrary = null;
|
|
|
|
}
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region SavePicture
|
|
|
|
public Picture SavePicture(string file, byte[] data)
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.SavePicture(file, data);
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Picture SavePicture(string file, Stream data)
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.SavePicture(file, data);
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region GetPictureFromToken
|
|
|
|
public Picture GetPictureFromToken(string file)
|
|
|
|
{
|
2012-08-25 21:22:30 +00:00
|
|
|
return nativeLibrary.GetPictureFromToken(file);
|
2012-01-16 20:08:38 +00:00
|
|
|
}
|
|
|
|
#endregion
|
2011-11-17 20:35:25 +00:00
|
|
|
}
|
|
|
|
}
|