Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/nutui-taro-demo/src/pages/index/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Taro from '@tarojs/taro'
import { View, Image, Text, ScrollView, Button, Input, Video } from '@tarojs/components'
import { View, Image, Text, ScrollView, Button, Input } from '@tarojs/components'
import pkg from '@/packages/../config.json'
import packageJson from '@/packages/../../package.json'
import './index.scss'
Expand All @@ -10,7 +10,7 @@ const navs = pkg.nav


// hack taro load button xml
console.log(Button, Input, Video )
console.log(Button, Input )

// try {
// console.log('xxx', Schema)
Expand Down
2 changes: 1 addition & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@
"author": "swag~jun"
},
{
"version": "3.0.0",
"version": "2.0.0",
"name": "Video",
"type": "component",
"cName": "视频播放器",
Expand Down
5 changes: 3 additions & 2 deletions src/packages/video/demo.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import Taro from '@tarojs/taro'
import { ScrollView, View } from '@tarojs/components'
import { useTranslate } from '@/sites/assets/locale/taro'

import Header from '@/sites/components/header'
import Demo1 from './demos/taro/demo1'
import Demo2 from './demos/taro/demo2'
Expand Down Expand Up @@ -45,7 +44,9 @@ const VideoDemo = () => {
return (
<>
<Header />
<ScrollView className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}>
<ScrollView
className={`demo full ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}
>
<View className="h2">{translated.basic}</View>
<Demo1 />
<View className="h2">{translated.autoPlay}</View>
Expand Down
7 changes: 3 additions & 4 deletions src/packages/video/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import { Cell, Video } from '@nutui/nutui-react-taro'
import pxTransform from '@/utils/px-transform'

const Demo1 = () => {
const [source] = useState({
const [source, setSource] = useState({
src: 'https://storage.360buyimg.com/nutui/video/video_NutUI.mp4',
type: 'video/mp4',
})
Expand All @@ -15,14 +14,14 @@ const Demo1 = () => {
const playend = (elm: any) => console.log('playend', elm)
return (
<>
<Cell style={{ padding: 0 }}>
<Cell style={{ padding: '0' }}>
<Video
source={source}
options={options}
onPlay={play}
onPause={pause}
onPlayEnd={playend}
style={{ height: pxTransform(163) }}
style={{ height: '163px' }}
/>
</Cell>
</>
Expand Down
7 changes: 3 additions & 4 deletions src/packages/video/demos/taro/demo2.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import { Cell, Video } from '@nutui/nutui-react-taro'
import pxTransform from '@/utils/px-transform'

const Demo2 = () => {
const [source] = useState({
const [source, setSource] = useState({
src: 'https://storage.360buyimg.com/nutui/video/video_NutUI.mp4',
type: 'video/mp4',
})
Expand All @@ -17,14 +16,14 @@ const Demo2 = () => {
const playend = (elm: any) => console.log('playend', elm)
return (
<>
<Cell style={{ padding: 0 }}>
<Cell style={{ padding: '0' }}>
<Video
source={source}
options={options}
onPlay={play}
onPause={pause}
onPlayEnd={playend}
style={{ height: pxTransform(163) }}
style={{ height: '163px' }}
/>
</Cell>
</>
Expand Down
7 changes: 3 additions & 4 deletions src/packages/video/demos/taro/demo3.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import { Cell, Video } from '@nutui/nutui-react-taro'
import pxTransform from '@/utils/px-transform'

const Demo3 = () => {
const [source] = useState({
const [source, setSource] = useState({
src: 'https://storage.360buyimg.com/nutui/video/video_NutUI.mp4',
type: 'video/mp4',
})
Expand All @@ -16,14 +15,14 @@ const Demo3 = () => {
const playend = (elm: any) => console.log('playend', elm)
return (
<>
<Cell style={{ padding: 0 }}>
<Cell style={{ padding: '0' }}>
<Video
source={source}
options={options}
onPlay={play}
onPause={pause}
onPlayEnd={playend}
style={{ height: pxTransform(163) }}
style={{ height: '163px' }}
/>
</Cell>
</>
Expand Down
5 changes: 2 additions & 3 deletions src/packages/video/demos/taro/demo4.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import { Cell, Video } from '@nutui/nutui-react-taro'
import pxTransform from '@/utils/px-transform'

const Demo4 = () => {
const [source] = useState({
const [source, setSource] = useState({
src: 'https://storage.360buyimg.com/nutui/video/video_NutUI.mp4',
type: 'video/mp4',
})
Expand All @@ -24,7 +23,7 @@ const Demo4 = () => {
onPlay={play}
onPause={pause}
onPlayEnd={playend}
style={{ height: pxTransform(163) }}
style={{ height: '163px' }}
/>
</Cell>
</>
Expand Down
7 changes: 3 additions & 4 deletions src/packages/video/demos/taro/demo5.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import { Cell, Video } from '@nutui/nutui-react-taro'
import pxTransform from '@/utils/px-transform'

const Demo5 = () => {
const [source] = useState({
const [source, setSource] = useState({
src: 'https://storage.360buyimg.com/nutui/video/video_NutUI.mp4',
type: 'video/mp4',
})
Expand All @@ -16,14 +15,14 @@ const Demo5 = () => {
const playend = (elm: any) => console.log('playend', elm)
return (
<>
<Cell style={{ padding: 0 }}>
<Cell style={{ padding: '0' }}>
<Video
source={source}
options={options}
onPlay={play}
onPause={pause}
onPlayEnd={playend}
style={{ height: pxTransform(163) }}
style={{ height: '163px' }}
/>
</Cell>
</>
Expand Down
7 changes: 3 additions & 4 deletions src/packages/video/demos/taro/demo6.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import { Cell, Video } from '@nutui/nutui-react-taro'
import pxTransform from '@/utils/px-transform'

const Demo6 = () => {
const [source] = useState({
const [source, setSource] = useState({
src: 'https://storage.360buyimg.com/nutui/video/video_NutUI.mp4',
type: 'video/mp4',
})
Expand All @@ -20,14 +19,14 @@ const Demo6 = () => {
const playend = (elm: any) => console.log('playend', elm)
return (
<>
<Cell style={{ padding: 0 }}>
<Cell style={{ padding: '0' }}>
<Video
source={source}
options={options}
onPlay={play}
onPause={pause}
onPlayEnd={playend}
style={{ height: pxTransform(163) }}
style={{ height: '163px' }}
/>
</Cell>
</>
Expand Down
13 changes: 6 additions & 7 deletions src/packages/video/demos/taro/demo7.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import { Cell, Video, Button } from '@nutui/nutui-react-taro'
import pxTransform from '@/utils/px-transform'

const Demo7 = () => {
const [source, setSource] = useState({
const [source1, setSource1] = useState({
src: 'https://storage.360buyimg.com/nutui/video/legao-%E6%9D%A8%E8%BF%9B%E5%86%9B.mp4',
type: 'video/mp4',
})
Expand All @@ -15,23 +14,23 @@ const Demo7 = () => {
const playend = (elm: any) => console.log('playend', elm)

const changeVideo = () => {
setSource({ ...source, src: 'https://vjs.zencdn.net/v/oceans.mp4' })
setSource1({ ...source1, src: 'https://vjs.zencdn.net/v/oceans.mp4' })
}
return (
<>
<Cell style={{ padding: 0 }}>
<Cell style={{ padding: '0' }}>
<Video
source={source}
source={source1}
options={options}
onPlay={play}
onPause={pause}
onPlayEnd={playend}
style={{ height: pxTransform(163) }}
style={{ height: '163px' }}
/>
</Cell>
<Button
type="primary"
style={{ marginBottom: pxTransform(60) }}
style={{ marginBottom: '60px' }}
onClick={changeVideo}
>
视频切换
Expand Down
11 changes: 7 additions & 4 deletions src/packages/video/video.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
BaseEventOrig,
View,
} from '@tarojs/components'
import { mergeProps } from '@/utils/merge-props'

export interface VideoProps extends Omit<VideoPropsTaro, 'src'> {
source: {
Expand All @@ -33,7 +32,7 @@ const defaultProps = {
},
options: {
controls: true,
muted: false,
muted: false, // 默认不是静音
autoplay: false,
poster: '',
playsinline: false,
Expand All @@ -44,6 +43,7 @@ const defaultProps = {
const classPrefix = `nut-video`
export const Video: FunctionComponent<Partial<VideoProps>> = (props) => {
const {
children,
source,
options,
className,
Expand All @@ -52,13 +52,16 @@ export const Video: FunctionComponent<Partial<VideoProps>> = (props) => {
onPause,
onPlayEnd,
...restProps
} = mergeProps(defaultProps, props)
} = {
...defaultProps,
...props,
}
const classes = classNames(classPrefix, className)

return (
<View className={classes} style={style}>
<VideoTaro
className={`${classPrefix}-player`}
className="nut-video-player"
muted={options.muted}
autoplay={options.autoplay}
loop={options.loop}
Expand Down
Loading