Taro实现微信小程序音乐播放

Taro实现微信小程序音乐播放


首页: 首页
分类页: 分类页
搜索页: 搜索页
列表 在这里插入图片描述 在这里插入图片描述

app.jsx

import Taro, { Component } from '@tarojs/taro'
import Index from './pages/index'
import { View, Text,Image } from '@tarojs/components'
import './app.less'
import 'taro-ui/dist/style/index.scss'

// 如果需要在 h5 环境中开启 React Devtools
// 取消以下注释:
// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5')  {
//   require('nerv-devtools')
// }

class App extends Component {

  config = {
      pages: [
        'pages/music/index',
        'pages/index/index',
        'pages/classify/index',
        'pages/user/index',
        'pages/videoPlay/index',
        'pages/music/hotSinger/index',
        'pages/music/singerSong/index',
        'pages/music/albumList/index',
        'pages/classify/playlist/index',
        'pages/player/index',
        'pages/recommendMv/index',
        'pages/songMenu/index',
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#d43c33',
      navigationBarTitleText: 'WeChat',
      navigationBarTextStyle: 'white'
    },
    tabBar: {
        color: "#666",
        selectedColor: "#b4282d",
        backgroundColor: "#fafafa",
        borderStyle: 'black',
        list: [
            {
            pagePath: "pages/music/index",
            iconPath: "./assets/tab-bar/yinyue1.png",
            selectedIconPath: "./assets/tab-bar/yinyue.png",
            text: "音乐"
            }, {
            pagePath: "pages/classify/index",
            iconPath: "./assets/tab-bar/icon1.png",
            selectedIconPath: "./assets/tab-bar/icon.png",
            text: "分类"
            }
            , {
            pagePath: "pages/index/index",
            iconPath: "./assets/tab-bar/sousuo1.png",
            selectedIconPath: "./assets/tab-bar/sousuo.png",
            text: "搜索"
            }
            // , {
            // pagePath: "pages/user/index",
            // iconPath: "./assets/tab-bar/geren1.png",
            // selectedIconPath: "./assets/tab-bar/geren.png",
            // text: "个人"
            // }
        ]
    },
    requiredBackgroundModes:['audio']
  }

  componentDidMount () {}

  componentDidShow () {}

  componentDidHide () {}

  componentDidCatchError () {}

  // 在 App 类中的 render() 函数没有实际作用
  // 请勿修改此函数
    render () {
        return (
            <Index /> 
        )
    }
}

Taro.render(<App />, document.getElementById('app'))

因为Taro.getBackgroundAudioManager()只支持微信小程序,所以打包成H5失效

github链接

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值