u1204 163 sourcelist

本文提供了一步一步的指南来帮助用户配置和使用163及搜狐镜像源,以提高Ubuntu系统的软件包更新和安装速度。通过简单的步骤,用户可以轻松替换默认的Ubuntu源为更快速稳定的国内镜像。

http://mirrors.163.com/ubuntu-releases/


163源

deb http://mirrors.163.com/ubuntu/ precise main restricted
 deb-src http://mirrors.163.com/ubuntu/ precise main restricted
 deb http://mirrors.163.com/ubuntu/ precise-updates main restricted
 deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted
 deb http://mirrors.163.com/ubuntu/ precise universe
 deb-src http://mirrors.163.com/ubuntu/ precise universe
 deb http://mirrors.163.com/ubuntu/ precise-updates universe
 deb-src http://mirrors.163.com/ubuntu/ precise-updates universe
 deb http://mirrors.163.com/ubuntu/ precise multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise multiverse
 deb http://mirrors.163.com/ubuntu/ precise-updates multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse
 deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
 deb http://mirrors.163.com/ubuntu/ precise-security main restricted
 deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted
 deb http://mirrors.163.com/ubuntu/ precise-security universe
 deb-src http://mirrors.163.com/ubuntu/ precise-security universe
 deb http://mirrors.163.com/ubuntu/ precise-security multiverse
 deb-src http://mirrors.163.com/ubuntu/ precise-security multiverse
 deb http://extras.ubuntu.com/ubuntu precise main
 deb-src http://extras.ubuntu.com/ubuntu precise main

sohu源

deb http://mirrors.sohu.com/ubuntu/ precise main restricted
 deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted
 deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
 deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
 deb http://mirrors.sohu.com/ubuntu/ precise universe
 deb-src http://mirrors.sohu.com/ubuntu/ precise universe
 deb http://mirrors.sohu.com/ubuntu/ precise-updates universe
 deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe
 deb http://mirrors.sohu.com/ubuntu/ precise multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse
 deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
 deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
 deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted
 deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted
 deb http://mirrors.sohu.com/ubuntu/ precise-security universe
 deb-src http://mirrors.sohu.com/ubuntu/ precise-security universe
 deb http://mirrors.sohu.com/ubuntu/ precise-security multiverse
 deb-src http://mirrors.sohu.com/ubuntu/ precise-security multiverse
 deb http://extras.ubuntu.com/ubuntu precise main
 deb-src http://extras.ubuntu.com/ubuntu precise main

使用方式:

sudo gedit /etc/apt/sources.list

然后把里面的列表替换成上面的列表,保存退出即可,修改完之后最好刷新一下系统的源:

sudo apt-get update

系统修改方式:

事实上,Ubuntu 已经收录了国内大部分知名的源,所以无需上网查找。

打开软件中心 – 编辑 – 软件源 ,然后点击源的列表 – 其他站点:

然后可以自己选择一个源,建议163源,比较稳定

选中后,点击右下角的选择服务器即可!


package com.weishitech.qichechangtingyinyue.fragment.home; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.TextView; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.resource.bitmap.CircleCrop; import com.google.android.material.bottomsheet.BottomSheetDialog; import com.hfd.common.base.BaseActivity; import com.hfd.common.util.ToastUtil; import com.weishitech.qichechangtingyinyue.R; import com.weishitech.qichechangtingyinyue.bean.FavoriteManager; import com.weishitech.qichechangtingyinyue.bean.MusicBean; import com.weishitech.qichechangtingyinyue.bean.MusicCache; import com.weishitech.qichechangtingyinyue.bean.PlayHistoryManager; import com.weishitech.qichechangtingyinyue.bean.SharedMusicViewModel; import com.weishitech.qichechangtingyinyue.fragment.Adapter.RecentPlayAdapter; import com.weishitech.qichechangtingyinyue.utils.MusicPlayerManager; import java.util.ArrayList; import java.util.List; public class LyricsActivity extends BaseActivity { // UI Views TextView tv_back, tv_song_name, tv_sing_name, tv_start_time, tv_end_time; ImageView iv_sing_logo, iv_tj, iv_gd, iv_xh, iv_sys, iv_bf, iv_xys, iv_zjbf; SeekBar seekbar; private boolean fromSearch = false; private boolean isSingleLoop = false; // 单曲循环开关 private FavoriteManager favoriteManager; private boolean isCurrentSongFavorite = false; // 声明 ViewModel private SharedMusicViewModel sharedViewModel; // 播放管理器 private MusicPlayerManager playerManager; private boolean isBoundToCurrentSong = false; // 是否已绑定当前歌曲 // 数据接收字段 private String title, singer, coverUrl, musicUrl; private int songPosition,totalSongCount; // 进度更新 private final Handler handler = new Handler(); private final Runnable updateProgressRunnable = new Runnable() { @Override public void run() { if (playerManager != null && playerManager.isPlaying()) { int currentPosition = playerManager.getCurrentPosition(); int duration = playerManager.getDuration(); if (duration > 0) { seekbar.setMax(duration); seekbar.setProgress(currentPosition); // 更新时间文本(格式 mm:ss) tv_start_time.setText(formatTime(currentPosition)); tv_end_time.setText(formatTime(duration)); } } handler.postDelayed(this, 1000); // 每秒更新一次 } }; private List<MusicBean.DataBean> sourceList; @Override protected int setLayout() { return R.layout.activity_lyrics; } @Override protected void setView() { tv_back = fvbi(R.id.tv_back); iv_sing_logo = fvbi(R.id.iv_sing_logo); tv_song_name = fvbi(R.id.tv_song_name); tv_sing_name = fvbi(R.id.tv_sing_name); iv_tj = fvbi(R.id.iv_tj); iv_gd = fvbi(R.id.iv_gd); seekbar = fvbi(R.id.seekbar); tv_start_time = fvbi(R.id.tv_start_time); tv_end_time = fvbi(R.id.tv_end_time); iv_xh = fvbi(R.id.iv_xh); iv_sys = fvbi(R.id.iv_sys); iv_bf = fvbi(R.id.iv_bf); iv_xys = fvbi(R.id.iv_xys); iv_zjbf = fvbi(R.id.iv_zjbf); } @Override protected void setData() { Bundle bundle = getIntent().getExtras(); if (bundle != null) { title = bundle.getString("title"); singer = bundle.getString("singer"); coverUrl = bundle.getString("cover_url"); musicUrl = bundle.getString("music_url"); songPosition = bundle.getInt("position", -1); totalSongCount = bundle.getInt("total_count", 0); fromSearch = bundle.getBoolean("from_search", false); // 接收来源标记 // 接收来源列表(关键!) if (bundle.containsKey("source_list")) { sourceList = (List<MusicBean.DataBean>) bundle.getSerializable("source_list"); totalSongCount = sourceList.size(); // 再次确认长度 } if (songPosition < 0 || songPosition >= totalSongCount) { ToastUtil.showShortToast("歌曲位置无效"); finish(); return; } tv_song_name.setText(title); tv_sing_name.setText(singer); Glide.with(this) .load(coverUrl) .into(iv_sing_logo); } // 初始化播放器 //使用单例 playerManager = MusicPlayerManager.getInstance(); // 注册播放状态监听 setupPlaybackListener(); // 绑定当前歌曲(检查是否已在播放) bindToCurrentSong(); // 初始化收藏管理器 favoriteManager = FavoriteManager.getInstance(this); updateFavoriteState(); // 更新按钮状态 // 初始化 ViewModel sharedViewModel = new ViewModelProvider(this).get(SharedMusicViewModel.class); // 只要进入页面,就视为“播放此歌”,记录历史 if (title != null && musicUrl != null && coverUrl != null) { MusicBean.DataBean currentSong = new MusicBean.DataBean(); currentSong.setTitle(title); currentSong.setSinger(singer); currentSong.setCover(coverUrl); currentSong.setMusic(musicUrl); currentSong.setSongTime(formatTime(playerManager.getDuration())); // 可选 //记录播放历史 PlayHistoryManager.getInstance(this).addPlayRecord(currentSong); } } @Override protected void setClick() { tv_back.setOnClickListener(v -> finish()); iv_sys.setOnClickListener(v -> { if (songPosition <= 0) { ToastUtil.showShortToast("当前已是第一首"); return; } playMusicAtPosition(songPosition - 1); }); iv_xh.setOnClickListener(v -> { isSingleLoop = !isSingleLoop; if (isSingleLoop) { ToastUtil.showShortToast("已开启单曲循环"); iv_xh.setImageResource(R.mipmap.img_xh); // 假设有这个资源 } else { ToastUtil.showShortToast("已关闭单曲循环"); iv_xh.setImageResource(R.mipmap.img_xh); } }); iv_xys.setOnClickListener(v -> { if (songPosition >= totalSongCount - 1) { ToastUtil.showShortToast("当前已是最后一首"); return; } playMusicAtPosition(songPosition + 1); }); iv_tj.setOnClickListener(v -> { if (title == null || musicUrl == null) { ToastUtil.showShortToast("歌曲信息不完整"); return; } MusicBean.DataBean currentSong = new MusicBean.DataBean(); currentSong.setTitle(title); currentSong.setSinger(singer); currentSong.setCover(coverUrl); currentSong.setMusic(musicUrl); currentSong.setSongTime(formatTime(playerManager.getDuration())); // 可选 if (isCurrentSongFavorite) { // 已收藏 → 取消收藏 favoriteManager.removeFromFavorites(musicUrl); iv_tj.setImageResource(R.mipmap.img_tj); // 未收藏图标 ToastUtil.showShortToast("已取消收藏"); } else { // 未收藏 → 添加收藏 favoriteManager.addToFavorites(currentSong); iv_tj.setImageResource(R.mipmap.img_tj_u); // 已收藏图标 ToastUtil.showShortToast("已添加到我喜欢"); } isCurrentSongFavorite = !isCurrentSongFavorite; //通知所有页面,收藏列表已改变 List<MusicBean.DataBean> newList = favoriteManager.getFavoriteList(); sharedViewModel.notifyFavoriteChanged(newList); }); iv_zjbf.setOnClickListener(v -> showRecentPlayDialog()); // 播放/暂停按钮 iv_bf.setOnClickListener(v -> { if (!isBoundToCurrentSong) { ToastUtil.showShortToast("暂无歌曲信息"); return; } if (playerManager.isPlaying()) { playerManager.pause(); } else { playerManager.resume(); } updatePlayButtonIcon(); }); // SeekBar 拖动控制 seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { tv_start_time.setText(formatTime(progress)); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // 用户开始拖动 } @Override public void onStopTrackingTouch(SeekBar seekBar) { // 用户停止拖动,跳转到指定位置 if (playerManager != null && isBoundToCurrentSong) { playerManager.seekTo(seekbar.getProgress()); } } }); } private void bindToCurrentSong() { if (musicUrl == null || title == null || sourceList == null || sourceList.isEmpty()) return; // ✅ 来自搜索页?使用外部列表播放模式 if (fromSearch) { playerManager.playFromExternalList( this, sourceList, songPosition, "search_result" ); isBoundToCurrentSong = true; updatePlayButtonIcon(); startUpdatingProgress(); return; } // 否则走原有逻辑(可保留) boolean isPlaying = playerManager.isPlaying(); int currentPos = playerManager.getCurrentPlayingPosition(); if (isPlaying && currentPos == songPosition) { isBoundToCurrentSong = true; updatePlayButtonIcon(); startUpdatingProgress(); } else { playerManager.play(this, songPosition, musicUrl); isBoundToCurrentSong = true; updatePlayButtonIcon(); startUpdatingProgress(); } } private void setupPlaybackListener() { playerManager.setOnPlaybackStateChangedListener(new MusicPlayerManager.OnPlaybackStateChangedListener() { @Override public void onPlaying(int position) { if (position == songPosition) { runOnUiThread(() -> { updatePlayButtonIcon(); startUpdatingProgress(); }); } else { // 播放的是其他位置的歌曲 → 当前页面应暂停状态 runOnUiThread(() -> { stopUpdatingProgress(); iv_bf.setImageResource(R.mipmap.img_gc_bf); // 显示播放图标 }); } } @Override public void onPaused() { runOnUiThread(() -> { updatePlayButtonIcon(); stopUpdatingProgress(); }); } @Override public void onCompletion() { runOnUiThread(() -> { // 停止当前进度更新 stopUpdatingProgress(); seekbar.setProgress(0); tv_start_time.setText("00:00"); if (isSingleLoop) { // 重新播放当前歌曲 playerManager.play(LyricsActivity.this, songPosition, musicUrl); startUpdatingProgress(); updatePlayButtonIcon(); } else { // 自动播放下一首 int nextPosition = songPosition + 1; if (nextPosition < totalSongCount) { playMusicAtPosition(nextPosition); } else { // 已到最后 → 可选:循环播放第一首 or 提示 ToastUtil.showShortToast("已播放完毕"); updatePlayButtonIcon(); // 显示为暂停状态 // 如果你想循环回第一首,取消下面注释 playMusicAtPosition(0); } } }); } @Override public void onError(String errorMsg) { runOnUiThread(() -> { ToastUtil.showShortToast("播放出错:" + errorMsg); updatePlayButtonIcon(); stopUpdatingProgress(); }); } }); } private void updatePlayButtonIcon() { if (playerManager.isPlaying()) { iv_bf.setImageResource(R.mipmap.img_gc_zt); // 暂停图标 } else { iv_bf.setImageResource(R.mipmap.img_gc_bf); // 播放图标 } } private void startUpdatingProgress() { stopUpdatingProgress(); // 防止重复 handler.postDelayed(updateProgressRunnable, 0); } private void stopUpdatingProgress() { handler.removeCallbacks(updateProgressRunnable); } @Override public void onResume() { super.onResume(); // 页面可见时尝试恢复状态 if (isBoundToCurrentSong) { updatePlayButtonIcon(); } } @Override protected void onPause() { super.onPause(); // 可选:不移除监听,让后台也能播放 } @Override protected void onDestroy() { stopUpdatingProgress(); // 注意:不要 release() playerManager,否则其他页面会中断 // playerManager.release(); ❌ 不要在这里释放 super.onDestroy(); } // 时间格式化工具 private String formatTime(int milliseconds) { int seconds = milliseconds / 1000; int minutes = seconds / 60; seconds = seconds % 60; return String.format("%02d:%02d", minutes, seconds); } private void playMusicAtPosition(int pos) { // 使用 MusicCache 判断边界(替代 musicDataList) if (pos < 0 || pos >= totalSongCount) { return; // 越界防护 } MusicBean.DataBean song; if (sourceList != null && pos < sourceList.size()) { song = sourceList.get(pos); } else { // 回退到主列表(兼容主列表播放) song = MusicCache.getMusicAt(pos); } // 播放指定位置的音乐 playerManager.play(this, pos, song.getMusic()); // 更新界面 updateUIForNewSong(song, pos); } /** * 播放新歌时更新界面和内部状态 */ private void updateUIForNewSong(MusicBean.DataBean song, int position) { // 更新成员变量 this.title = song.getTitle(); this.singer = song.getSinger(); this.coverUrl = song.getCover(); this.musicUrl = song.getMusic(); this.songPosition = position; // 更新 UI 显示 tv_song_name.setText(title); tv_sing_name.setText(singer); if (isDestroyed() || isFinishing()) return; Glide.with(this) .load(coverUrl) .into(iv_sing_logo); // 标记已绑定当前歌曲 isBoundToCurrentSong = true; // 更新播放按钮为“正在播放” updatePlayButtonIcon(); // 开始进度条更新 startUpdatingProgress(); // 可选:Toast 提示 ToastUtil.showShortToast("播放: " + title); updateFavoriteState(); PlayHistoryManager.getInstance(this).addPlayRecord(song); } private void updateFavoriteState() { if (musicUrl == null) { iv_tj.setImageResource(R.mipmap.img_tj); isCurrentSongFavorite = false; return; } isCurrentSongFavorite = favoriteManager.isFavorite(musicUrl); iv_tj.setImageResource(isCurrentSongFavorite ? R.mipmap.img_tj_u : R.mipmap.img_tj); } private void showRecentPlayDialog() { // 创建 BottomSheetDialog BottomSheetDialog dialog = new BottomSheetDialog(this); // 绑定布局 View contentView = getLayoutInflater().inflate(R.layout.dialog_recent_play, null); dialog.setContentView(contentView); // 找控件 TextView tvTitle = contentView.findViewById(R.id.tv_title); RecyclerView rvRecent = contentView.findViewById(R.id.rv_recent); // 加载数据 PlayHistoryManager historyManager = PlayHistoryManager.getInstance(this); List<MusicBean.DataBean> historyList = historyManager.getHistoryList(); tvTitle.setText("最近播放 (" + historyList.size() + ")"); // 设置适配器 RecentPlayAdapter adapter = new RecentPlayAdapter(); rvRecent.setLayoutManager(new LinearLayoutManager(this)); rvRecent.setAdapter(adapter); adapter.setData(historyList); if (musicUrl != null) { adapter.setCurrentPlayingSong(musicUrl); // 传入当前播放的 musicUrl } // 设置点击事件 adapter.setOnItemClickListener((song, position) -> { // 跳转到该歌曲的歌词页 playMusicAtPositionFromHistory(song); dialog.dismiss(); // 关闭弹窗 }); // 显示 dialog.show(); } private void playMusicAtPositionFromHistory(MusicBean.DataBean song) { // 查找当前 sourceList 中是否有这首歌 int pos = -1; if (sourceList != null) { for (int i = 0; i < sourceList.size(); i++) { if (sourceList.get(i).getMusic().equals(song.getMusic())) { pos = i; break; } } } // 如果没找到,默认为 0 或添加进临时播放? if (pos == -1) { // 可选择重新构造列表,或将它作为单曲播放 pos = 0; List<MusicBean.DataBean> temp = new ArrayList<>(); temp.add(song); sourceList = temp; totalSongCount = 1; } updateUIForNewSong(song, pos); playerManager.play(this, pos, song.getMusic()); ToastUtil.showShortToast("正在播放:" + song.getTitle()); } } 一直提示 ToastUtil.showShortToast("播放出错:" + errorMsg);
最新发布
12-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值