No Description

ShortVideoProgressView.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /**
  2. * Created by zack on 2018/4/19.
  3. */
  4. import {
  5. View,
  6. Text,
  7. Image,
  8. StyleSheet,
  9. TouchableHighlight,
  10. ImageBackground
  11. } from 'react-native'
  12. import React, { PureComponent } from "react";
  13. import ScreenDimensions from '../../../utils/ScreenDimensions'
  14. import ScreenDimensionsClientHeight from '../../../utils/ScreenDimensions'
  15. import NavigationBarHeight from '../../../utils/NavigationBarHeight'
  16. import TabBarHeight from '../../../utils/TabBarHeight'
  17. import RefreshInfiniteListView from '../../../utils/RefreshInfiniteListView'
  18. import Video from 'react-native-video'
  19. import CusProgressBar from '../../../utils/CusProgressBar'
  20. //ScreenDimensions.clientHeight
  21. export default class ShortVideoProgressView extends PureComponent {
  22. constructor(props) {
  23. super(props)
  24. this.state = {
  25. leftText: "",
  26. rightText: ""
  27. }
  28. }
  29. componentDidMount() {
  30. }
  31. componentWillReceiveProps(nextProps) {
  32. if (nextProps.selectedPages !== this.props.selectedPages) {
  33. this.setState({
  34. rate: nextProps.selectedPages
  35. })
  36. }
  37. }
  38. render() {
  39. let fullIcon = require('../../../resources/images/TabBar/Community/ShortVideo/suo.png');
  40. return (
  41. <View style={{flex:1}}>
  42. <View style={styles.playInStyles}>
  43. <View style={styles.leftPlayInStyle}>
  44. <Text style={styles.leftTextStyle}> {this.state.leftText}</Text>
  45. </View>
  46. <CusProgressBar ref={(ref) => {
  47. this.progressBar = ref
  48. }} style={styles.progresStyle} />
  49. <View style={styles.rightPlayInStyle}>
  50. <Text style={styles.totalTimer}>{"3:00"}</Text>
  51. </View>
  52. <TouchableHighlight
  53. underlayColor={"rgba(255,255,255,0)"}
  54. onPress={this.onPressFullScreen.bind(this)}>
  55. <View style={styles.rightBtn}>
  56. <Image source={fullIcon} style={styles.fullStyle} />
  57. </View>
  58. </TouchableHighlight>
  59. </View>
  60. </View>
  61. )
  62. }
  63. onPressFullScreen(){
  64. //全屏
  65. this.props.fullScreen()
  66. }
  67. setProgressValue(value,timestamp){
  68. this.progressBar.progress=value;
  69. let time = this.timestampToTime(timestamp)
  70. this.setState({
  71. leftText:time
  72. })
  73. }
  74. timestampToTime(timestamp) {
  75. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  76. Y = date.getFullYear() + '-';
  77. M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
  78. D = date.getDate() + ' ';
  79. h = date.getHours() + ':';
  80. m = date.getMinutes()<10?"0"+date.getMinutes()+ ':':date.getMinutes() + ':';
  81. s = date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds();
  82. return m+s;
  83. }
  84. }
  85. const styles = StyleSheet.create({
  86. playInStyles: {
  87. width: ScreenDimensions.width,
  88. height: 25,
  89. flexDirection: "row",
  90. alignItems:"center",
  91. marginTop:30,
  92. },
  93. leftPlayInStyle: {
  94. marginLeft: 5,
  95. marginRight: 5,
  96. flex: 1,
  97. justifyContent:"center",
  98. alignItems:"center"
  99. },
  100. progresStyle: {
  101. height: 5,
  102. flex: 6
  103. },
  104. rightPlayInStyle: {
  105. flex: 1,
  106. justifyContent:"center",
  107. alignItems:"center"
  108. },
  109. rightBtn: {
  110. flex: 1,
  111. justifyContent:"center",
  112. alignItems: "center",
  113. marginHorizontal:15,
  114. },
  115. fullStyle:{
  116. width:27/2,
  117. height:27/2
  118. },
  119. totalTimer:{
  120. fontSize:12,
  121. color:"#ffffff"
  122. },
  123. leftTextStyle:{
  124. fontSize:12,
  125. color:"#ffffff"
  126. }
  127. })