As part of the Private Edge Challenge Series, the object was to build a mobile application that would allow users to utilize a video news feed.
Video News Feeds Application Challenge using AlefEdge EdgeNet Video Enablement API.
Here I will discuss my solution and approach to the requirements during the development of the application.
The challenge required users to be able to view and load news feed videos in a low-latency environment using the Private Edge Video Enablement API.
The user should also be able to tag that video as a favorite or “save for later”. We could add additional features for users to be able to search videos based on their news feed title.
I chose the following technology stack:
Backend:
Alefedge Video Enablement API for video Storage in EdgeNet,
Firebase for video storage (copy of the video if Edgenet URL fails to load),
Firebase for user authentication as well as storing video metadata such as images, titles, genre and description.
Frontend: Android using Kotlin
Exoplayer Library for video and audio player to play different video format types such as Clear DASH, HLS, and smooth streaming,
Material UI as theme and styling library,
Android Architecture using Model View ViewModel (Android Lifecycle aware component),
Room for local database,
Coroutines with RxJava for network calls,
Android unit testing.
The three APIs I focused on from Video Enablement Api Swagger.
Add content to server: /api/v1/stream-tech/content/add
Get all content details for given partner: /api/v1/stream-tech/content/get-all
Get URL for the given content ID : /api/v1/stream-tech/content/get-url/{content_id}
To use the APIs we need two values ‘Api Key’ and ‘Partner Name’.
I followed Alefedge User Guide Documentation provided on the Alefedge website to gather both these values to use the APIs.
The content_id field uniquely identifies the video content in both the Firebase and Alefedge video storage.
Response to posting video to EdgeNet (/api/v1/stream-tech/content/add)
1 2 3 4 5 6 7 8 9 10
{ "URLs": [ { "message": "Content onboarding is in progress", "status": "INPROGRESS", "url": "https://d29ctshu25jfop.cloudfront.net/aa/raw.mp4", "content_id": "bdt" } ] }
Firebase FireStore is used for user authentication, storing video metadata, and copying of videos if Edgenet fails to load.
I added videos to the Edgenet and FireStore cloud storage for a different type of media.
HLS type with (.m3u8) , Dash(.mpd),Smooth Streaming(.ism/Manifest) and also other progressive formats such as (.mp4)
Code snippet for EdgeNetService using Retrofit Get Call.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//Retrofit ApiEdgeNetService Service
interface ApiEdgeNetService {
@GET("api/v1/stream-tech/content/get-all")
suspend fun getAllContent(
@Query("partner_name") partner_name: String = AESEncyption.decrypt(Constants.PARTNER_ID) !!,
@Header("api_key") api_key: String = AESEncyption.decrypt(Constants.API_KEY) !!
): Response < EdgeNetCloud >
@GET("api/v1/stream-tech/content/get-url/{content_id}")
suspend fun getContentId(
@Path("content_id") content_id: String,
@Query("partner_name") partner_name: String = AESEncyption.decrypt(Constants.PARTNER_ID) !!,
@Header("api_key") api_key: String = AESEncyption.decrypt(Constants.API_KEY) !!
): Response < EdgeNetUrl >
}
Sign in and sign up UI components using Firebase Authentication for the backend.
Once a user logs in with their username and password the application lands on the homepage which has a BottomNavigationView, containing three screens:
Trending videos
Channels (clicking on Channel will open videos corresponding to that particular channel)
Watch later (favorites and bookmark).
Favorites and bookmark data are stored in the local DB using Room Database.
Lifecycle-aware LiveData and ViewModels were used so that the view layer can be updated when underlying data changes.
Network calls were made with the help of Kotlin Coroutines and RxJava.
Video player component using Google’s open source Exoplayer Library.
This guide Developer Guide for Exoplayer helped in understanding and handling different media types such as HLS, DASH, and smooth streaming.
Android unit testing for network module, view models, and database:
Android test for network module
1
2
3
4
5
6
7
8
9
10
11
12
var apiClient = getRetrofitClient(Constants.EDGENET_CLOUD);
var api = apiClient.create(ApiEdgeNetService::class.java)
@Test
fun getEdgeNetExistingVideo() {
runBlocking {
var s = api.getContentId("bev")
Assert.assertNotNull(s?.body())
}
}
# This code part of the file is not the complete code.
Android test for database
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
@get: Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()
private lateinit
var db: FavouriteShowDatabase
private lateinit
var dbdao: FavouriteShowDao
@Before
public override fun setUp() {
val application = ApplicationProvider.getApplicationContext < Context > ()
db = Room.inMemoryDatabaseBuilder(application, FavouriteShowDatabase::class.java)
.allowMainThreadQueries()
.build() //only for testing
dbdao = db.tvFacouritesDao()
}
@Test
fun writeAndReadFavourites() {
val favourite = Favourites("Travel", "https:://image", "https:://url", "bev", "F", "Movie")
dbdao.addToWatchList(favourite)
.blockingAwait()
dbdao.selectAll()
.test()
.assertValue {
list - >
list.isNotEmpty()
}
}
@After
fun closeDB() {
db.clearAllTables()
db.close()
}
}
# This code part of the file is not the complete code.
This challenge helped me understand how to use the EdgeNet Video Enablement API effectively to store and retrieve information, make a video player component using OpenSource Exoplayer to handle different types of media types, and to use modern architecture components along with Room Database to build components for Android App.
Video Link of Application: https://drive.google.com/file/d/10D-vWKOdMeu5jPKDWARYPp1YvySrpgsA/view?usp=sharing