導航:首頁 > 源碼編譯 > 小程序完整多音頻播放源碼

小程序完整多音頻播放源碼

發布時間:2022-12-12 19:36:50

① 微信小程序音頻播放之音樂播放器

使用微信小程序實現一個簡易的音樂播放器.
Github地址

雖然界面很簡單,但是一個音頻播放器該有的功能大部分都有了(沒有歌詞顯示功能).
主要實現的功能有:
1.實現音頻播放,暫停;
2.實現拖拽進度條,快進音頻進度;
3.實現上一首,下一首,列表循環播放;
4.實現關閉小程序,也可在後台播放,正式版需要通過審核,開發版本可正常測試;

一丶index.js

二丶index.wxml

三丶index.wxss

四丶要實現關閉小程序後,依然後台播放,微信頂部懸浮展示,需要再app.json配置requiredBackgroundModes屬性

附上官方相關api鏈接:
BackgroundAudioManager.html
wx.getBackgroundAudioManager()
slider組件

② 求一個java音樂播放器的源代碼

import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.EndOfMediaEvent;
import javax.media.PrefetchCompleteEvent;
import javax.media.RealizeCompleteEvent;
import javax.media.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MediaPlayer extends JFrame implements ActionListener,
ItemListener, ControllerListener {
String title;

Player player;
boolean first = true, loop = false;
Component vc, cc;
String currentDirectory=null;
// 構造函數,其中包括了設置響應窗口事件的監聽器。
MediaPlayer(String title) {
super(title);
/* 關閉按鈕的實現。。 */
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
}

public void windowClosed(WindowEvent e) {
if (player != null)
player.close();
System.exit(0);
}

});
// 調用程序菜單欄的方法成員完成菜單的布置
setupMenu();
setSize(400, 400);
setVisible(true);
}

// 本方法用以設置程序菜單欄
public void setupMenu() {
// 設置一個菜單
Menu f = new Menu("文件");
// 往設置的菜單添加菜單項
MenuItem mi = new MenuItem("打開");
f.add(mi);
mi.addActionListener(this);
f.addSeparator();
CheckboxMenuItem cbmi = new CheckboxMenuItem("循環", false);
cbmi.addActionListener(this);
f.add(cbmi);
f.addSeparator();
MenuItem ee = new MenuItem("退出");
ee.addActionListener(this);
f.add(ee);
f.addSeparator();

Menu l = new Menu("播放列表");
Menu c = new Menu("播放控制");
MenuItem move = new MenuItem("播放");
move.addActionListener(this);
c.add(move);
c.addSeparator();
MenuItem pause = new MenuItem("暫停");
pause.addActionListener(this);
c.add(pause);
c.addSeparator();
MenuItem stop = new MenuItem("停止");
stop.addActionListener(this);
c.add(stop);
c.addSeparator();
// 設置一個菜單欄
MenuBar mb = new MenuBar();
mb.add(f);
mb.add?;
mb.add(l);
// 將構造完成的菜單欄交給當前程序的窗口;
setMenuBar(mb);
}

// 動作時間響應成員;捕捉發送到本對象的各種事件;
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String cufile, selectfile, currentDirectory;
if (e.getActionCommand().equals("退出")) {
// 調用dispose以便執行windowClosed
dispose();
return;
}
// 此事表明擁護選擇了「播放」命令;
// 如果當前有一個文件可以播放則執行播放命令;
if (e.getActionCommand().equals("播放")) {
if (player != null) {
player.start();
}
return;
}
// 如果當前正在播放某一文件,則執行暫停;
if (e.getActionCommand().equals("暫停")) {
if (player != null) {
player.stop();
}
return;
}
// 停止命令的響應;
if (e.getActionCommand().equals("停止")) {
if (player != null) {
player.stop();
player.setMediaTime(new Time(0));
}
return;
}
// 用戶選擇要播放的媒體文件
if (e.getActionCommand().equals("打開")) {
FileDialog fd = new FileDialog(this, "打開媒體文件", FileDialog.LOAD);
// fd.setDirectory(currentDirectory);

2008-2-6 02:46 回復

肆方茉莉
62位粉絲
6樓

fd.setVisible(true);
// 如果用戶放棄選擇文件,則返回
if (fd.getFile() == null) {
return;
}
// 保存了所選文件的名稱及其路徑名稱已被稍後使用
// 同時設置當前文件夾路徑
selectfile = fd.getFile();
currentDirectory = fd.getDirectory();
cufile = currentDirectory + selectfile;
// 將用戶選擇的文件作為一個菜單項加入播放列表,該菜單項名為該文件名;
// 被點擊後給出的命令串是該文件的全路徑名
MenuItem mi = new MenuItem(selectfile);
mi.setActionCommand(cufile);
MenuBar mb = getMenuBar();
Menu m = mb.getMenu(2);
mi.addActionListener(this);
m.add(mi);
} else {
// 程序邏輯運行到次表示用戶選擇了一個「播放列表」中的媒體文件
// 此時可以通過如下動作獲得該文件的全路徑名
cufile = e.getActionCommand();
selectfile = cufile;
}
// 如果存在一個播放器,則先將其關閉,稍後再重新創建
// 創建播放器時需要捕捉一些異常
if (player != null) {
player.close();
}
try {
player = Manager.createPlayer(new MediaLocator("file:" + cufile));
} catch (Exception e2) {
System.out.println(e2);
return;
}/*
* catch(NoPlayerException e2){ System.out.println("不能找到播放器");
* return ; }
*/
if (player == null) {
System.out.println("無法創建播放器");
return;
}
first = false;
setTitle(selectfile);
// 設置處理播放控制器實際的對象;
/**/
player.addControllerListener(this);
player.prefetch();
}

// 菜單狀態改變事件的響應函數;
public void itemStateChanged(ItemEvent arg0) {
// TODO Auto-generated method stub

}
public static void main(String[] args) {
// TODO Auto-generated method stub
new MediaPlayer("播放器");
}

// 調用繪圖函數進行界面的繪制 // public void update() {
// }
// 繪圖函數成員 //public void paint(Graphics g) {
// }
public void controllerUpdate(ControllerEvent e) {
// TODO Auto-generated method stub
Container tainer = getContentPane();
// 調用player.close()時ControllerClosedEvent事件出現
// 如果存在視覺部件,則該部件應該拆除(為了一致起見,我們對控制面版部件也執行同樣的操作,下一次需要時再構造)
if (e instanceof ControllerClosedEvent) {
if (vc != null) {
remove(vc);
vc = null;
}
if (cc != null) {
remove(cc);
cc = null;
}
}

// 播放結束時,將播放指針置於文件之首,如果設定了循環播放,則再次啟動播放器;
if (e instanceof EndOfMediaEvent) {
player.setMediaTime(new Time(0));
if (loop) {
player.start();
}
return;
}

// PrefetchCompletEvent事件發生後調用start,正式啟動播放
if (e instanceof PrefetchCompleteEvent) {
player.start();
return;
}

// 本事件表示由於播放的資源已經確定;此時要將媒體的圖形conmopnent
// 如果有顯示出來,同時將播放器player的控制顯示到窗口裡;
if (e instanceof RealizeCompleteEvent) {
// 如果媒體中有圖像,將對應圖像component載入窗體;
vc = player.getVisualComponent();
if (vc != null)
tainer.add(vc, BorderLayout.CENTER);
// 將對應控制器component載入窗體;
cc = player.getControlPanelComponent();
cc.setBackground(Color.blue);
if (cc != null)
tainer.add(cc, BorderLayout.SOUTH);
// 有一些特殊媒體在播放時提供另外的控制手段,將控制器一並加入窗口;
/*
* gc=player.getGainControl(); gcc=gc.getControlComponent();
* if(gcc!=null) tainer.add(gcc,BorderLayout.NORTH);
*/
// 根據媒體文件中是否有圖像,設定相應的窗口大小
if (vc != null) {
pack();
return;
} else {
setSize(300, 75);
setVisible(true);
return;
}
}

} }

③ 小程序音頻後台播放

BackgroundAudioManager

1, 獲取實例

    const audio = wx.getBackgroundAudioManager();

    audio.title = "標題";   

    audio.src = "demo.mp3";

    src屬性改變後即自動播放音頻, 注意:title屬性 必填,否則 不報錯不播放。

    singer(歌手)  epname(專輯名) coverImgUrl(封面圖)等屬性 可選填

BackgroundAudioManager.play()     BackgroundAudioManager.pause()   兩個方法用來控制音頻播放 暫停  需要注意的是退出後台後  無法控制

④ 微信小程序源碼全套

目前小程序如果模板小程序是不提供源碼的,定製開發可以提供源碼。
第1種是賣模板為主的網路公司。
優點是:價格低,幾千塊錢到萬元之間就能搞定,方便,能夠快速上線;
缺點是:修改功能麻煩,這里需要避免低價陷阱,不要到最後才發現模板性的修改功能所花的錢比買模板還貴。而且不是獨立的,一個模本賣給很多商家用,模板不是永久使用的,一般每年都要交年費。
第2種是主流的方式,定製開發為主的網路公司。
優點是:獨一無二的,專為你的企業或者店面定製的,功能你來定,要求你來定,後期修改BUG方便,改東西也很方便,最重要的是永久使用權!!
缺點是:相對價格比較高!!! 定製版的基本費用在上萬元到十幾萬不等!不過貴也有貴的道理吧,畢竟功能做的更全面一點。
最後總結,至於找什麼樣的小程序開發公司?花多少錢來開發?還是需要看貴公司准備的預算這塊!希望對大家有用!

⑤ Github上收集了70個微信小程序源碼

1:仿豆瓣電影微信小程序
https://github.com/zce/weapp-demo

2:微信小程序移動端商城
https://github.com/liuxuanqiang/wechat-weapp-mall

3:Gank微信小程序
https://github.com/lypeer/wechat-weapp-gank

4:微信小程序高仿QQ應用
https://github.com/xiehui999/SmallAppForQQ
5:微信中的知乎
https://github.com/RebeccaHanjw/weapp-wechat-hu

6:實現一個移動端小商城
https://github.com/skyvow/m-mall

7:微信小程序demo
https://github.com/web-Marker/wechat-Development

8: 跑步微信小程序Demo
https://github.com/alanwangmodify/weChatApp-Run

9:簡單的v2ex微信小程序
https://github.com/jectychen/wechat-v2ex

10:騰訊雲微信小程序
https://github.com/tencentyun/weapp-client-demo

11:微信小程序-微票
https://github.com/wangmingjob/weapp-weipiao

12:微信小程序demo 仿手機淘寶
https://github.com/ChangQing666/wechat-weapp-taobao

13:一個為微信小程序開發准備的基礎骨架
https://github.com/zce/weapp-boilerplate

14:巴爺微信商城的簡單版本
https://github.com/bayetech/wechat_mall_applet

15:微信小程序 - 電影推薦
https://github.com/yesifeng/wechat-weapp-movie
16:微信小程序-知乎日報
https://github.com/myronliu347/wechat-app-hudaily

17:微信小程序: 音樂播放器
https://github.com/eyasliu/wechat-app-music

18:使用微信小程序實現分答這款APP的基礎功能
https://github.com/davedavehong/fenda-mock

19:微信小程序開發demo-地圖定位
https://github.com/giscafer/wechat-weapp-mapdemo

:20:微信小程序 - 豆瓣電影
https://github.com/hingsir/weapp-douban-film

21:wepy仿微信聊天界面
https://github.com/wepyjs/wepy-wechat-demo

22:仿 「ONE · 一個」 的微信小程序
https://github.com/ahonn/weapp-one

23:微信小程序集成Rex實現的Todo list
https://github.com/charleyw/wechat-weapp-rex-todos

24: 基於Zhihu Live數據的微信小程序
https://github.com/dongweiming/weapp-hulive

25:微信小程序之小熊の日記
https://github.com/harveyqing/BearDiary

26:仿網易雲音樂APP的微信小程序
https://github.com/sqaiyan/netmusic-app

27:微信小程序的Flex布局demo
https://github.com/icindy/wxflex

28:番茄時鍾微信小程序版
https://github.com/kraaas/timer

29:Wafer 服務端 Demo
https://github.com/tencentyun/weapp-node-server-demo

30:微信小程序版聊天室
https://github.com/ericzyh/wechat-chat

31:微信小程序版簡易計算器,適合入門練手
https://github.com/nizb/wxapp-sCalc

32:微信小程序示例一筆到底
https://github.com/CFETeam/weapp-demo-session

33:基於麵包旅行 API 製作的微信小程序示例
https://github.com/romoo/weapp-demo-breadtrip

34:新聞閱讀器
https://github.com/vace/wechatapp-news-reader

35:一個簡單的微信小程序購物車DEMO
https://github.com/SeptemberMaples/wechat-weapp-demo

36:微信小程序-公眾號熱門文章信息流
https://github.com/hijiangtao/weapp-newsapp

37:通過Node.js實現的妹子照片爬蟲微信小程序
https://github.com/litt1e-p/weapp-girls

38:從FlexLayout布局開始學習微信小程序
https://github.com/hardog/wechat-app-flexlayout

39:HiApp 微信小程序版
https://github.com/BelinChung/wxapp-hiapp

40:微信小程序的簡單嘗試
https://github.com/zhengxiaowai/weapp-github

41:集美大學圖書館的便捷工具
https://github.com/ToadWoo/bookbox-wxapp

42:微信小程序版妹紙圖

https://github.com/brucevanfdm/WeChatMeiZhi

43:V2ex 微信小程序版
https://github.com/bestony/weapp-V2ex

44:微信小程序仿百思不得姐
https://github.com/SureZhangHW/WXBaiSi

45:微信小程序音樂播放器應用
https://github.com/xingbofeng/wx-audio

46:醫葯網原生APP的微信小程序DEMO
https://github.com/jiabinxu/yiyaowang-wx

47:微信小程序跟讀
https://github.com/gxmzjxk/wxreading

48:微信小程序瀑布流布局模式
https://github.com/icindy/WxMasonry

49:微信小程序HotApp雲筆記
https://github.com/hotapp888/hotapp-notepad

50:小程序模仿——網易雲音樂

https://github.com/MengZhaoFly/wechatApp-netease_cloudmusic

51:微信小程序商城demo
https://github.com/lin-xin/wxapp-mall

52:微信小程序版的掃雷
https://github.com/jsongo/wx-mime

53:專注管理時間的微信小程序
https://github.com/SeaHub/PigRaising

54:微信小程序版干貨集中營
https://github.com/iwgang/GankCamp-WechatAPP

55:英雄聯盟(LOL)戰績查詢
https://github.com/xiaowenxia/weapp-lolgame

56:微信小程序首字母排序選擇表
https://github.com/icindy/wxSortPickerView

57:微信小程序版豆瓣電影
https://github.com/David-Guo/weapp-douban-movie

58:簡單的實現了1024的游戲規則
https://github.com/RedLove/WexinApp_1024

59:微信小程序試玩
https://github.com/uniquexiao/wechat-app-githubfeed

60:微信小程序逗樂
https://github.com/mkxiansheng/doule

61:一步步開發微信小程序
https://github.com/Gavin-YYC/wxApp

62:一個 meteor 的 React todo list 例子
https://github.com/leijing7/wx-mina-meteor

63:微信小程序健康菜譜
https://github.com/bestTao/caipu_weixin

64: jspapa微信小程序版本
https://github.com/biggerV/jspapa-wx

65:微信小程序版的CNodeJs中文社區
https://github.com/Shaman05/CNodeJs-WXAPP

66:LeanCloud 的微信小程序用戶登陸Demo
https://github.com/bestony/weapp-LeanCloud

67: 微笑話微信小程序
https://github.com/zszdevelop/wejoke

68:微信小程序開發的App
https://github.com/chongbenben/liwushuoapp

69:體育新聞微信小程序

https://github.com/havenxie/weapp-sportsnews

70:基於Labrador和mobx構建的小程序開發demo
https://github.com/spacedragon/labrador_mobx_example

⑥ 可以存放好幾個音頻的微信小程序

audio音頻播放
這個不僅可以設置多個音頻,還可以多個音頻一起播放,並且互不幹擾。

⑦ 網頁音樂播放器HTML源碼

一、在ASPASP.Net MVC音樂播放的HTML代碼網頁。

⑧ 直播小程序源碼的開發原理

主播端使用 <live-pusher> ,它在微信小程序的內部是一個推流引擎,它負責對手機攝像頭和麥克風的數據進行採集和編碼,並通過 url 參數指定的 rtmp 推流地址上傳到雲端。
雲端的作用類似信號放大器,它負責將來自主播端的一路音視頻流數據進行放大,將數據實時並且無差異的負責並擴散到全國各地。觀眾端使用 <live-player> 進行播放,它在小程序的內部是一個在線播放器,負責從雲端實時拉取音視頻數據並進行解碼和渲染。

⑨ 微信小程序Demo源碼怎麼找在哪裡下載

微信小程序的Demo源碼有很多種。我平時找小程序的Demo源碼都是在即速應用bbs這個小程序開發論壇上找的,裡面的資源基本上可以滿足各類開發人群的需求。而且都是可以直接下載的。

閱讀全文

與小程序完整多音頻播放源碼相關的資料

熱點內容
ospfpdf 瀏覽:712
安卓耳機聲音小怎麼設置 瀏覽:196
程序員升級win11後 瀏覽:594
雲伺服器怎麼調出控制面板 瀏覽:171
python正則表達式函數 瀏覽:632
把自己公司的源碼給別人 瀏覽:436
典韋真的要出程序員皮膚嗎 瀏覽:680
程序員如何轉行做電腦維修 瀏覽:395
4mz演算法 瀏覽:831
程序員全部穿格子圖片 瀏覽:921
申通取件加密 瀏覽:817
顏色改變命令 瀏覽:679
海口童程童美學編程怎麼樣 瀏覽:694
vb編程未找到方法 瀏覽:239
三國戰記命令 瀏覽:922
程序員穿運動鞋 瀏覽:505
自來水公司需要電腦編程 瀏覽:309
金融app如何從銀行卡扣款 瀏覽:556
網站的源碼修改成自己的 瀏覽:802
本科生程序員是初級嗎 瀏覽:639