net.sf.zekr.engine.audio
Class PlaylistProvider

java.lang.Object
  extended by net.sf.zekr.engine.audio.PlaylistProvider
All Implemented Interfaces:
IPlaylistProvider
Direct Known Subclasses:
OfflinePlaylistProvider, OnlinePlaylistProvider

public abstract class PlaylistProvider
extends java.lang.Object
implements IPlaylistProvider

Author:
Mohsen Saboorian

Field Summary
protected  AudioData audioData
           
protected  int pageNum
           
 
Fields inherited from interface net.sf.zekr.engine.audio.IPlaylistProvider
SPECIAL_END, SPECIAL_PRESTART, SPECIAL_START
 
Constructor Summary
PlaylistProvider(AudioData audioData, int pageNum)
           
 
Method Summary
 AudioData getAudioData()
           
 int getItem(int sura, int aya)
          Deprecated. since AudioData.SURA_PLAYLIST is deprecated.
 int getSpecialItem(java.lang.String name)
          Default implementation for special audio item index lookup.
abstract  java.lang.String providePlaylist()
          Provides playlist file path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

audioData

protected AudioData audioData

pageNum

protected int pageNum
Constructor Detail

PlaylistProvider

public PlaylistProvider(AudioData audioData,
                        int pageNum)
Method Detail

providePlaylist

public abstract java.lang.String providePlaylist()
                                          throws PlaylistProvisionException
Description copied from interface: IPlaylistProvider
Provides playlist file path. If this is an online provider, it just returns the absolute URL to playlist. If offline, and playlist doesn't already exist, first creates the playlist and returns URL to that.

Specified by:
providePlaylist in interface IPlaylistProvider
Returns:
URL for provided playlist
Throws:
PlaylistProvisionException

getItem

public int getItem(int sura,
                   int aya)
Deprecated. since AudioData.SURA_PLAYLIST is deprecated.

Default getItem behavior is implemented in this class, and can be overridden for special playlists.
If audio data is in sura mode, this method does return aya - 1;, regardless of sura/aya number, since in sura mode every sura has a corresponding playlist in which each playling item (counted from 0) is mapped exactly to its corresponding aya (counted from 1).
For audio data in collection mode assumption is that sura items are located regularly one sura after the other in natural Quran order. So exact number of an item for sura i is equal to aggregative sum of aya count from sura 1 to sura i - 1 plus aya parameter - 1:
(for sura: 1 to sura parameter) ∑(aya count) + aya parameter - 1

Specified by:
getItem in interface IPlaylistProvider
Parameters:
sura - sura number in which corresponding aya should be returned as a playlist item. This parameter is 1-based.
aya - aya number to be resolved to an item. This parameter is 1-based.
Returns:
playlist item to be played, corresponding to the given sura/aya number. This number is 0-based.

getAudioData

public AudioData getAudioData()
Specified by:
getAudioData in interface IPlaylistProvider
Returns:
AudioData object for the playlist

getSpecialItem

public int getSpecialItem(java.lang.String name)
Default implementation for special audio item index lookup. This implementation assumes that special items are located at the end of playlist (if any): SPECIAL_PRESTART, SPECIAL_START, and SPECIAL_END respectively.

Specified by:
getSpecialItem in interface IPlaylistProvider
Parameters:
name - the name of special audio item
Returns:
special audio item index, or -1 if there is no such item for the playlist