You are currently viewing Enabling Live Streaming of Sessions in the Open Event Android App

Enabling Live Streaming of Sessions in the Open Event Android App

The Open Event Android App had no option for viewing session videos if the links for them were provided by the event organiser. This post walks through how viewing of session videos was made possible through use of implicit intents which launched the Youtube app if the video link was a Youtube link and what all possible cases were taken into account so as to provide the user to view the video of a session as described below:

What is the current status of the app?

The current SessionDetailActivity.java containing the detail of the sessions of the event looks like this:

Adding Live Streaming option in the app

A live streaming feature is added in the app which enables the user to view the session. Now there were certain edge cases which needed to be handled:

  • No video links provided in the sessions json file

In that case the SessionDetailActivity.java looked the way it looks above as there is no way we can enable the live streaming option as the live video links aren’t provided by the event organiser.

  • The video links are provided but are not Youtube links

In that case the SessionDetailActivity.java looks like this, where the card view has a grey background showing that the user will be directed to the required link on a click.

  • The video links are Youtube links

In that case the Youtube thumbnail is fetched through Picasso and is made as the card view background. The SessionDetailActivity.java looks like this in such a case:

First the link is checked whether it is a Youtube link or not as illustrated in the code snippet below:

if(!Utils.isEmpty(video_link)) {
    playButton.setVisibility(View.VISIBLE);

    if(video_link.contains(ConstantStrings.YOUTUBE)) {

        Picasso.with(this)
               .load(youtubeLink)
               .into(youtubeThumbnail);
    
        youtubeThumbnail.setVisibility(View.VISIBLE);
    }

}

After the link is guaranteed as a Youtube link the play icon click is handled. On clicking the play icon, the user is directed to a Youtube app for the viewing of a session through an implicit intent using this piece of code:

playButton.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {

        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(video_link)));

    }

});

Thus the user is given an option to view the live streaming of a session, if the video links are provided by the event organiser.

Related Links:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.