Customer Sign In

upLynk

Android SDK Extras

Using the AAR file

You must use the Uplynk player AAR file instead of the JAR file to use these features. The AAR file contains the JAR file in addition to some required Android resources.

How to use it

  1. Edit android/app/build.gradle and add the AAR dependency
  2. android/app/build.gradle
    1
    2
    3
    4
    dependencies {
        ...
        compile(name:'upLynkLib-release', ext:'aar')
    }
    
  3. Edit android/build.gradle and add the "flatDir" directive to the "allprojects" section, where "libs" is the location of the AAR file
  4. android/build.gradle
    1
    2
    3
    4
    5
    6
    7
    8
        allprojects {
            repositories {
                ...
                flatDir {
                    dirs 'libs'
                }
            }
        }
    

MediaController

Screenshot of MediaController

Android’s stock MediaController is a set of on-screen controls for video playback. It provides Play/Pause, Fast-Forward, Rewind, Previous, and Next buttons, as well as a seek bar with playback time info.

Uplynk’s MediaController builds on the stock MediaController by adding functionality like:

  • CC/Subtitle display settings and channel selection
  • Audio channel selection, and volume controls
  • Text fields for displaying Title, episode, other info
  • Preview thumbnail while seeking
  • Display of content and ad segments in the seekbar

It is available in the Uplynk Player Library build 96 and later.

How to use it

  1. Change import from android.widgets.MediaController to com.uplynk.media.widgets.MediaController
  2. Implement additions to the MediaController.MediaPlayerControl interface:
  3. MediaController.MediaPlayerControl additionsBuild 96
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    /**
     * Gets a list of audio tracks
     * @return vector of UplynkTrackInfo objects
     */
    Vector<MediaPlayer.UplynkTrackInfo> getAudioTracks();
    
    /**
     * Select an audio track
     * @param trackNum 0-based index
     */
    void selectAudioTrack(int trackNum);
    
    /**
     * Gets a list of subtitle tracks
     * @return vector of UplynkTrackInfo objects
     */
    Vector<MediaPlayer.UplynkTrackInfo> getSubtitleTracks();
    
    /**
     * Select a subtitle track
     * @param trackNum 0-based index
     */
    void selectSubtitleTrack(int trackNum);
    
    /**
     * Turn caption display on or off
     * @param enabled True to display captions, false to hide
     */
    void setCaptionsEnabled(boolean enabled);
    
    /**
     * Sets the display style for captions
     * @param style com.uplynk.media.CaptionStyle object
     */
    void setCaptionStyle(CaptionStyle style);
    
    /**
     * Sets the volume
     * @param volume Value range 0.0 to 1.0
     */
    void setVolume(float volume);
    
    /**
     * Read if the currently playing media is a live stream (vs. VOD)
     *
     * @return true if live, false if VOD
     */
    boolean isLive();
    
    /**
     * Get the segment map, which comes from the MediaPlayer's
     * onUplynkSegmentList(MediaPlayer mp, Vector<MediaPlayer.UplynkSegment> segments) call-back
     */
    Vector<MediaPlayer.UplynkSegment> getSegmentMap();
    

    Most of these interface functions can be simple pass-through functions to call the corresponding functions in the MediaPlayer class.

    Example
    1
    2
    3
    4
    5
    6
    7
    8
    public Vector<MediaPlayer.UplynkTrackInfo> getAudioTracks()
    {
        if(_mediaPlayer != null)
        {
            return _mediaPlayer.getAudioTrackOptions();
        }
        return null;
    }
    
  4. Update call to setAnchorView() from:
  5. setAnchorView(View)
    1
    _mediaController.setAnchorView((View) _surfaceView.getParent());
    

    to

    setAnchorView(FrameLayout)Build 96
    1
    _mediaController.setAnchorView((FrameLayout) _surfaceView.getParent());
    

    Additional Features and Customizations

    Dialog Styles

    Two types of dialogs can be shown: the FULL_DIALOG type will show a CaptionSettings or AudioSettings dialog, or TRACK_SELECTION_ONLY will show the TrackSelector dialog. (The dialogs can also be used separately from the MediaController)

    Set Dialog TypeBuild 96
    1
    2
    3
    4
    5
    6
    7
    /**
     * Changes the type of dialog shown for the CC and Audio dialogs
     *
     * @param subtitleDialogType FULL_DIALOG, or TRACK_SELECTION_ONLY
     * @param audioDialogType    FULL_DIALOG, or TRACK_SELECTION_ONLY
     */
    public void setDialogType(DialogTypes subtitleDialogType, DialogTypes audioDialogType)
    

    Caption Styles

    Caption style settings in the CC dialog can be initialized and applied to the MediaPlayer. Must be called after setMediaPlayer() has been called.

    Initialize CaptionsBuild 96
    1
    2
    3
    4
    5
    6
    7
    /**
     * Initialize captions to the style given. The captionStyle could be stored in the app and
     * restored on startup. Must be called after setMediaPlayer() has been called.
     * @param captionStyle the caption style
     * @param channelNum   the subtitle track number to default to
     */
    public void initializeCaptions(boolean captionsEnabled, CaptionStyle captionStyle, int channelNum)
    

    Title Text Fields

    The three ‘Title’ text fields can be set or hidden using NULL. Hidden by default.

    Title Text FieldsBuild 96
    1
    2
    3
    4
    5
    6
    7
    8
    /**
     * Set the 'Title' text fields at the top of the screen
     *
     * @param largeText  text to display or null to hide
     * @param mediumText text to display or null to hide
     * @param smallText  text to display or null to hide
     */
    public void setTitleText(String largeText, String mediumText, String smallText)
    

    References

    Android MediaController (android.widget.MediaController)

AudioSettings Dialog

Screenshot of Audio dialog

The AudioSettings class displays a dialog allowing the user to select an audio track and to set the playback volume. Also handles the selections and interacts with the MediaPlayer via MediaPlayerControl.

AudioSettingsBuild 96
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
/**
 * Constructor
 *
 * @param context       The activity's context
 * @param playerControl interface class using com.uplynk.widgets.MediaController.MediaPlayerControl
 */
public AudioSettings(Context context, com.uplynk.widgets.MediaController.MediaPlayerControl playerControl)

/**
 * Shows the dialog. Changes are applied immediately upon selection.
 */
public void showDialog()

CaptionSettings Dialog

Screenshot of Captions dialog

The CaptionSettings class displays a dialog allowing the user to select font and background styles for displaying subtitles. Also handles the selections and interacts with the MediaPlayer via MediaPlayerControl.

CaptionSettingsBuild 96
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 /**
 * Constructor
 *
 * @param context       The activity's context
 * @param playerControl interface class using com.uplynk.widgets.MediaController.MediaPlayerControl
 */
public CaptionSettings(Context context, com.uplynk.widgets.MediaController.MediaPlayerControl playerControl)

 /**
 * Displays the dialog for choosing caption settings. On 'Apply', the settings are set using
 * the MediaController interface. On 'Cancel' or other dismissal, no changes are applied.
 */
public void showDialog()

TrackSelector Dialog

Screenshot of subtitle track selection Screenshot of audio track selection

Shows a dialog for audio or subtitle tracks, and then handles the user input.

TrackSelectorBuild 96
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 /**
 * Constructor
 * @param context       The activity's context
 * @param playerControl interface class using com.uplynk.widgets.MediaController.MediaPlayerControl
 */
public TrackSelector(Context context, MediaController.MediaPlayerControl playerControl)

/**
 * Displays the track selection dialog. Dialog is dismissed upon selection and the selection
 * is applied to the MediaPlayer
 * @param selectionType The type of track to select: AUDIO or SUBTITLES
 */
public void showTrackOptions(TrackSelectionType selectionType)

UplynkTrackAdapter ArrayAdapter

An ArrayAdapter for the MediaPlayer.UplynkTrackInfo class

UplynkTrackAdapter extends ArrayAdapter<MediaPlayer.UplynkTrackInfo> Build 96
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public UplynkTrackAdapter(Context context, int textViewResourceId, List<MediaPlayer.UplynkTrackInfo> objects)

@Override
public int getCount()

@Override
public MediaPlayer.UplynkTrackInfo getItem(int position)

@Override
public long getItemId(int position)

@Override
public View getView(int position, View convertView, ViewGroup parent)

SeekBarSegmentedTrack Drawable

A Drawable class that can be used in place of SeekBar's default seek track via Seekbar.setProgressDrawable(Drawable d). It displays content and ad segments in the colors specified by CONTENT_COLOR and AD_COLOR fields. The segment map is updated by calling setSegmentMap(...)

SeekBarSegmentedTrack extends DrawableBuild 96
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public static int AD_COLOR;
public static int CONTENT_COLOR;

/**
 * Constructor
 */
public SeekBarSegmentedTrack()

/**
 * Set the segment map data to be used for drawing the track
 * @param segmentMap Vector of UplynkSegment's
 */
public void setSegmentMap(Vector<MediaPlayer.UplynkSegment> segmentMap)