① 微信小程序音频播放之音乐播放器
使用微信小程序实现一个简易的音乐播放器.
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这个小程序开发论坛上找的,里面的资源基本上可以满足各类开发人群的需求。而且都是可以直接下载的。