Android 手機影音 開發過程記錄(一)

開發工具

  • Android Studio
  • JDK 1.8

版本兼容

  • Android 4.1及以上

效果圖

這裏寫圖片描述 這裏寫圖片描述

這裏寫圖片描述

這裏寫圖片描述 這裏寫圖片描述

主要有視頻和音樂功能模塊:

  • 視頻模塊:

    1. 視頻列表-將手機sd卡的視頻列出來
    2. 自定義播放器界面
    3. 萬能播放器(能播放主流格式的視頻)
    4. 視頻播放界面一些細節和邏輯的處理
  • 音樂模塊:

    1. 音樂列表-將手機sd卡的音樂列出來
    2. 在Service中播放音樂
    3. 播放模式的切換和邏輯處理
    4. 自定義佈局的通知
    5. 歌詞的解析和同步顯示

應用整體結構圖

這裏寫圖片描述

這裏就可以做一些開發前的準備工作。像BaseActivity和BaseFragment的編寫。

包名的組織

這裏寫圖片描述

這裏只是大致地組織了一下該應用開發要用到的包名,實際開發視每個具體的應用而定。後期可添加。

SplashActivity的編寫

  • 功能一: 默認延遲3秒進入主頁面
  • 功能二: 支持點擊立即進入主頁面

注意點:爲防止進入主頁面的方法被執行兩次(默認的一次以及觸摸的一次),應在進入主頁面的方法外加一個判斷標識。

相關代碼如下:
佈局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/base_bg"
    android:gravity="center"
    android:orientation="vertical">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:text="好音樂,好心情"
        android:textColor="@color/white"
        android:textSize="18sp" />

</LinearLayout>

SplashActivity代碼

public class SplashActivity extends Activity {

    private boolean hasEnter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        delayEnterMain(true);
    }

    private void delayEnterMain(boolean isdelay) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (!hasEnter) {
                    hasEnter = true;
                    goToMain();
                }
            }
        }, isdelay ? 3000 : 0);
    }

    private void goToMain() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                delayEnterMain(false);
                break;
        }
        return super.onTouchEvent(event);
    }
}

好了,先整理到這裏。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章