PRM392 - Mobile Programming
Instructor: NGUYEN PHUC VUONG
TOUCH MUSIC
ANDROID APPLICATION
Group 2
LE QUOC CU - CE171592
BACH TRUNG TIEN - CE171840
NGO VIET NGUYEN - CE171903
HUA KHANH HUY - CE171778
VO DAI TINH - CE160507
PRM392
SP25
TABLE OF CONTENTS
1. Project Overview
2. Objective and Scope
2.1. Object
2.2. Scope
3. Application architecture
3.1. Overall Architecture
3.2. Key Components
4. Application Workflow
5. Technologies and Libraries used
6. Core Features
7. Database and DAO
7.1. Entity
7.2. DAO
7.3. Room Database
8. API and Retrofit
8.1. Retrofit Configuration
8.2. API Endpoints
9. System flow diagram
10. User Case Diagram
11. Testing and Quality Assurance
11.1. Tested Features
11.2. Test Devices
11.3. Results
12. Evaluation and Conclusion
12.1. Strengths
12.2. Limatations
12.3. Conclusion
2
PRM392
SP25
1. Project Overview
This is a music streaming application developed on the Android platform with core features such
as: music playback, song search, Top 100 chart display, and favorite song management. The app
fetches music data via APIs, including ZingMP3 and another backend API (possibly self-hosted
on localhost:5000).
The app is developed with academic goals in mind, applying knowledge of Android Jetpack
components, MVVM architecture, local data management, and RESTful API integration, toward
a practical product.
2. OBJECTIVES AND SCOPE
2.1. Objectives
Develop a simple and user-friendly music player app.
Integrate online music streaming via APIs.
Allow user to search, favorite, and manage songs.
Apply MVVM architecture and modern Android libraries.
2.2. Scope
Entire application designed and developed in Java.
Supports Android devices from API level 24 and above.
Music data is fetched from APIs (local backend or third-party service).
No login or cloud sync features implemented yet.
3. Application architecture
3.1. Overall Architecture
MVVM Architecture: Separation of View, ViewModel, and Model
Single Activity Architecture: One main activity with multiple fragments.
Room Database: Local storage of favorite songs.
ExoPlayer: Efficient and powerful music playback.
Retrofit: Simple and efficient API communication.
Glide: Smooth image loading and caching.
3
PRM392
SP25
3.2. Key Components
Song.java, SongDao, AppDatabase
ApiService, ApiClient, Response classes
MusicRepository, MusicPlayerService
MainActivity, SearchFragment, Top100Fragment, MyListFragment
SongAdapter, ViewPagerAdapter
4. Application Workflow
Launch the app → load main interface.
Call Top 100 API → display list of songs.
User searches or selects a song to play.
Stream music via ExoPlayer from URL.
User can favorite a song → save to Room.
UI updates in real-time using LiveData.
5. Technologies and Libraries Used
AndroidX: ViewPager2, LiveData, Room, Fragment
Retrofit2 + GsonConverter + OkHttp3
Glide (images), ExoPlayer (media)
Room Database (offline storage)
Service (Media Control in background)
Material Design Components.
4
PRM392
SP25
6. Core Features
6.1. Song search
User inputs keywords → calls searchSongs() → results shown via RecyclerView.
6.2. Top 100
Calls getTop100() API → displays list of popular songs.
6.3. Play song
User selects → sends ID → fetches stream URL from getSongSource() → plays with
ExoPlayer.
6.4. Favorite/Unfavorite Song
Updates isFavorite status → saves to Room DB → LiveData observes and updates UI.
6.5. Favorite List
Displays songs where isFavorite = true in MyListFragment.
7. DATABASE & DAO
7.1. Entity - Song.java
@Entity(tableName = "songs")
public class Song {
@PrimaryKey
@NonNull
private String id;
private String name;
private String singer;
private String path;
private String image;
private boolean isFavorite;
private String duration;
5
PRM392
SP25
public Song() {}
@Ignore
public Song(String id, String name, String singer, String
path, String image) {
this.id = id;
this.name = name;
this.singer = singer;
this.path = path;
this.image = image;
this.isFavorite = false;
}
// Getters and Setters
}
7.2. DAO - SongDao.java
@Dao
public interface SongDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(Song song);
@Update
void update(Song song);
@Delete
void delete(Song song);
@Query("DELETE FROM songs WHERE id = :songId")
void deleteSongById(String songId);
@Query("SELECT * FROM songs")
LiveData<List<Song>> getAllSongs();
@Query("SELECT * FROM songs WHERE id = :songId")
Song getSongById(String songId);
6
PRM392
SP25
@Query("SELECT EXISTS(SELECT 1 FROM songs WHERE id = :songId
LIMIT 1)")
boolean songExists(String songId);
}
7.3. Room Database - AppDatabase.java
@Database(entities = {Song.class}, version = 1, exportSchema =
false)
public abstract class AppDatabase extends RoomDatabase {
private static final String DATABASE_NAME =
"music_player_db";
private static AppDatabase instance;
public abstract SongDao songDao();
public static synchronized AppDatabase getInstance(Context
context) {
if (instance == null) {
instance = Room.databaseBuilder(
context.getApplicationContext(),
AppDatabase.class,
DATABASE_NAME
).build();
}
return instance;
}
}
8. API & RETROFIT
8.1. Retrofit Configuration - ApiClient.java
public class ApiClient {
private static final String BASE_URL = "https://your-apiurl.com/api/";
public static Retrofit getRetrofit() {
return new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create
())
.build();
}
}
8.2. API Endpoints - ApiService.java
public interface ApiService {
@GET("top100")
Call<Top100Response> getTop100();
7
PRM392
SP25
@GET("search")
Call<SearchResponse> searchSongs(@Query("keyword") String
keyword);
@GET("song")
Call<SongResponse> getSongById(@Query("id") String songId);
@GET("getSongSource")
Call<SongInfoResponse> getSongSource(@Query("id") String
songId);
@GET("getChartRealtime")
Call<DetailPlaylistResponse> getChartRealtime();
}
9. SYSTEM FLOW DIAGRAM
flowchart TD
A[Launch App] --> B[Call Top 100 API]
B --> C[Display Songs]
C --> D[Click to Play Song]
D --> E[Call getSongSource API]
E --> F[Play using ExoPlayer]
F --> G[Show MiniPlayer + Notification]
C --> H[Favorite Song] --> I[Save to Room DB
10. User Case Diagram
8
PRM392
SP25
11. Testing and Quality Assurance
11.1. Tested Feature
Song Search
Streaming from API
Favorite / Unfavorite songs
Display favorite songs list
11.2. Test Device:
Xiaomi (Android 10)
Samsung Galaxy A50 (Android 11)
11.3. Result
100% of features worked as expected. No critical issues found
12. Evaluation and Conclusion
12.1. Strengths
Modern app with up-to-date technologies.
Clean and smooth UI.
MVVM architecture supports scalability.
Offline functionality for favorites.
12.2. Limitations
No user login system.
No personal playlist feature.
Depends on external API services which may be limited.
12.3. Conclusion
9
PRM392
SP25
Touch Music is a high-quality academic project that demonstrates full integration of modern
Android development practices—from backend API handling to local data management. With
further improvements, the app could evolve into a deployable commercial product.
THE END!
10