CNLiveTVPlayerViewController.swift 106 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227
//
//  CNLivePlayerViewController.swift
//  metaCode
//
//  Created by zx on 2025/1/21.
//

import Foundation
import ZFPlayer
import MJRefresh
import HandyJSON
import CNLiveShareToolKit
import CNLivePayCostModule
import MBProgressHUD

class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITableViewDelegate{
    
    //专辑付费内容记录
    var payVodAlbumListModel:CNLiveVodAlbumListModel?
    var payContentId = ""
    var payAid = ""//专辑albumid
    var payAlbumListArr = NSMutableArray()
    var payIndex = 0
    var payTitle = ""
    var payIsAlbum = false
    var payActivityId = ""
    var isPayZhuanJi = false//是否付过费
    var payVodProductModel:CNLiveAlbumProductModel?
    
    //当前选择内容是否需要付费
    var currentPlayIsNeedPay = false
    
    
    var player: CNLiveZFPlayerController!
    //当前内容id
    var contentId = ""
    var playTitle = ""
    var isSeek = false
    
    
    //当前播放列表 专辑true / 看点false
    var isPlayAblumOrKandian = false
    var isAblumVideo = false
    //专辑列表数组   播放专辑时用
    lazy var albumListArr: NSMutableArray = {
        var dataArray = NSMutableArray()
        return dataArray
    }()
    var albumIndex:Int = 0//当前专辑播放index
    
    //看点列表数组   播放看点时用
    lazy var kanDianListArr: NSMutableArray = {
        var dataArray = NSMutableArray()
        return dataArray
    }()
    var kanDianIndex:Int = -1//当前看点播放index
    
    //CNLiveVodPlayModel 单集model
    var _vodPlayModel : CNLiveVodPlayModel?
    var vodPlayModel : CNLiveVodPlayModel? {
        get{
            _vodPlayModel
        }
        set{
            _vodPlayModel = newValue!
        }
    }
    
    var vodPlayBlockListList5Model:CNLiveVodPlayBlockListListModel?//点播详情数据

    // 专辑列表model
    var _vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel?
    var vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel? {
        get{
            _vodAlbumListBaseModel
        }
        set{
            _vodAlbumListBaseModel = newValue!
        }
    }
    
    //playerUrl
    var _url:URL?
    var url:URL? {
        get{
            return _url
        }
        set{
            _url = newValue!
        }
    }
    
    let kCNLiveVodIntroductionCellIdentifier = "kCNLiveVodIntroductionCellIdentifier"
    let kCNLiveVodAlbumListCellIdentifier = "kCNLiveVodAlbumListCellIdentifier"
    let kCNLiveVodTrailersCellIdentifier = "kCNLiveVodTrailersCellIdentifier"
    let kCNLiveVodPlayShopCellIdentifier = "kCNLiveVodPlayShopCellIdentifier"

    
    lazy var tableView : UITableView = {
        let tableView = UITableView(frame: .zero, style: .plain)
        tableView.dataSource = self
        tableView.delegate = self
        tableView.separatorStyle = .none
        tableView.register(CNLiveVodIntroductionCell.self, forCellReuseIdentifier: kCNLiveVodIntroductionCellIdentifier)
        tableView.register(CNLiveVodAlbumListCell.self, forCellReuseIdentifier: kCNLiveVodAlbumListCellIdentifier)
        tableView.register(CNLiveVodTrailersCell.self, forCellReuseIdentifier: kCNLiveVodTrailersCellIdentifier)
        tableView.register(CNLiveVodPlayShopCell.self, forCellReuseIdentifier: kCNLiveVodPlayShopCellIdentifier)
        
        tableView.backgroundColor = .white
        return tableView
    }()
    ///数据源
    lazy var dataArray: NSMutableArray = {
        var dataArray = NSMutableArray()
        return dataArray
    }()
    
    lazy var bottomCommentShowContainView :UIView = {
        let iconImgView = UIView()
        iconImgView.backgroundColor = .clear
        return iconImgView
    }()
    lazy var bottomCommentView :UIView = {
        let iconImgView = UIView(frame: CGRect(x: 0, y: KSreenHeight-60-KTabBarSafeHeight, width: KSreenWidth, height: 60))
        iconImgView.backgroundColor = .white
        iconImgView.isUserInteractionEnabled = true
        iconImgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(bottomCommentViewTapAction)))
        return iconImgView
    }()
    lazy var bottomCommentTalkView :UIView = {
        let iconImgView = UIView()
        iconImgView.layer.borderColor = HexColor("#979797")?.cgColor
        iconImgView.layer.borderWidth = 0.5
        iconImgView.layer.cornerRadius = 20
        iconImgView.clipsToBounds = true
        return iconImgView
    }()
    lazy var bottomCommentLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.text = "我来说几句…"
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.font = Font_14
        return titleLabel
    }()
    lazy var bottomCommentImgView :UIImageView = {
        let iconImgView = UIImageView()
        iconImgView.image = UIImage(named: "home_player_comment")
        return iconImgView
    }()
    lazy var bottomCommentNumLabel: UILabel = {
        let titleLabel = UILabel()
        titleLabel.text = ""
        titleLabel.textColor = HexColor("#FFFFFF")
        titleLabel.backgroundColor = HexColor("#FF0000")
        titleLabel.textAlignment = .center
        titleLabel.font = UIFont.systemFont(ofSize: 9)
        titleLabel.layer.cornerRadius = 5
        titleLabel.clipsToBounds = true
        return titleLabel
    }()


    lazy var whitBgView :UIView = {
        let iconImgView = UIView(frame: CGRect(x: 0, y: KStatusBarHeight, width: KSreenWidth, height: KSreenHeight-KStatusBarHeight))
        iconImgView.backgroundColor = .white
        return iconImgView
    }()
    lazy var containerView :UIImageView = {
        let iconImgView = UIImageView(frame: CGRect(x: 0, y: KStatusBarHeight, width: KSreenWidth, height: KSreenWidth*9/16))
        iconImgView.image = UIImage.imageWithColor(color: UIColor.black, size: CGSize(width: 1, height: 1))
        return iconImgView
    }()
    lazy var controlView :CNLiveZFPlayerControlView = {
        let controlView = CNLiveZFPlayerControlView()
        controlView.fastViewAnimated = true
        controlView.autoHiddenTimeInterval = 5
        controlView.autoFadeTimeInterval = 0.5
        controlView.prepareShowLoading = true
        controlView.prepareShowControlView = false
        controlView.showCustomStatusBar = true
        return controlView
    }()
        
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.handleScreenCaptureChange()
        navigationController?.interactivePopGestureRecognizer?.isEnabled = false
    }
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        print("1111111viewDidDisappear:\(metaAppDelegate.isCaptured)")
        self.player.currentPlayerManager.pause()
        // 恢复手势识别
//        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
        navigationController?.interactivePopGestureRecognizer?.isEnabled = true
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .black
        self.view.addSubview(self.whitBgView)
        self.view.addSubview(self.containerView)
                
        let backBtn = UIButton.backItem(imageName: ("mine_header_icon_white_back"), target: self, action: #selector(ClickBackBtn))
        backBtn.frame = CGRect(x: 15, y: KStatusBarHeight, width: backBtn.width, height: backBtn.height)
        self.view.addSubview(backBtn)
//        backBtn.backgroundColor = .red
        
        view.addSubview(tableView)
        tableView.frame = CGRect(x: 0, y: self.containerView.bottom, width: KSreenWidth, height: KSreenHeight-self.containerView.bottom-KTabBarSafeHeight-60)
        view.addSubview(self.bottomCommentView)
        self.bottomCommentView.addSubview(self.bottomCommentTalkView)
        bottomCommentTalkView.snp.makeConstraints { make in
            make.top.left.equalToSuperview().offset(10)
            make.width.equalToSuperview().offset(-75)
            make.height.equalTo(40)
        }
        self.bottomCommentView.addSubview(self.bottomCommentLabel)
        bottomCommentLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(25)
            make.centerY.equalToSuperview()
            make.width.equalTo(100)
            make.height.equalTo(20)
        }
        self.bottomCommentView.addSubview(self.bottomCommentImgView)
        bottomCommentImgView.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-20)
            make.centerY.equalToSuperview()
            make.width.equalTo(25)
            make.height.equalTo(24)
        }
        self.bottomCommentImgView.addSubview(self.bottomCommentNumLabel)
        bottomCommentNumLabel.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(7.5)
            make.top.equalTo(-5)
            make.width.equalTo(15)
            make.height.equalTo(10)
        }
        
        self.view.addSubview(self.bottomCommentShowContainView)
        bottomCommentShowContainView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalToSuperview().offset(self.containerView.bottom)
            make.width.equalToSuperview()
            make.height.equalToSuperview().offset(-self.containerView.bottom)
        }
        bottomCommentShowContainView.isHidden = true
//        self.addRefreshView()//测试使用 ,正式别打开!!!
        self.isAblumVideo = false
        self.isPlayAblumOrKandian = false
        
//        if let albumModel = self.vodAlbumListBaseModel{
        if self.vodPlayModel?.album?.albumId.count ?? 0 > 0{
            //专辑
            self.isAblumVideo = true
            self.isPlayAblumOrKandian = true
        }else{
            //单集
            self.isAblumVideo = false
            self.isPlayAblumOrKandian = false
        }
        self.configDataArray()
        self.setupPlayer()
        
        
        if  metaAppDelegate.isLogin{
            let pid = (self.vodPlayBlockListList5Model?.pid.count ?? 0 > 0) ? (self.vodPlayBlockListList5Model?.pid ?? "") : (self.vodPlayBlockListList5Model?.contentId ?? "")
            CNLiveShortVideoViewModel.requestCommentList(pid: pid, page: 1) {[weak self] result, respStatue in
                guard let self = self else { return }
                if respStatue == .success {
                    let total_hd = (result as! ShortVideoHomeCommentModel).total_hd ?? 0
                    if total_hd == 0{
                        self.bottomCommentNumLabel.isHidden = true
                    }else{
                        self.bottomCommentNumLabel.isHidden = false
                        self.bottomCommentNumLabel.text = "\(total_hd)"
                    }
                    
                }
            }
        }else{
            self.bottomCommentNumLabel.isHidden = true
        }
        
        
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(appDidEnterBackground),
            name: UIApplication.didEnterBackgroundNotification,
            object: nil
        )
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(appDidEnterPlayGround),
            name: UIApplication.didBecomeActiveNotification,
            object: nil
        )
        
        //录屏状态实时检测‌ 监听
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(handleScreenCaptureChange),
            name: UIScreen.capturedDidChangeNotification,
            object: nil
        )
        //登录成功通知
        NotificationCenter.default.addObserver(self, selector: #selector(CNLiveReportUserRefreshCommentSuccessNotificationAction), name: Notification.Name.VodManage.CNLiveReportUserSuccessRefreshCommentListNotification, object: nil)
        
        // 直接关闭手势识别
//        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
    }

    @objc func CNLiveReportUserRefreshCommentSuccessNotificationAction() {
        //举报用户成功 刷新评论列表
        if let commmentListView = self.bottomCommentShowContainView.viewWithTag(1000) as? CNLiveShortVideoCommentListView{
            commmentListView.isReset = true
            commmentListView.pageNum = 0
            commmentListView.requestDataSource()
        }
    }

    
    @objc func appDidEnterBackground() {
        self.pausePlayerIfNeed()
    }
    @objc  func appDidEnterPlayGround() {
        self.playPlayerIfNeed()
    }
    func pausePlayerIfNeed(){
        //如果录屏中 或后台 暂停
        self.player.currentPlayerManager.pause()
    }
    func playPlayerIfNeed(){
        //如果没录屏 且 当前不是需要付费内容 可以播放
        if !self.currentPlayIsNeedPay{
            self.player.currentPlayerManager.play()
        }
    }
    
    @objc private func handleScreenCaptureChange() {
        if metaAppDelegate.isCaptured {
            showPrivacyProtection()
        } else {
            hidePrivacyProtection()
        }
    }
    // 显示保护层(模糊效果)
    private func showPrivacyProtection() {
        self.hidePrivacyProtection()
        
        if self.player.isFullScreen{
            //全屏 横屏
            let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .regular))
            blurView.frame = self.controlView.landScapeControlView.bounds
            blurView.tag = 10001
            self.controlView.landScapeControlView.addSubview(blurView)
            
            let vc = self.controlView.landScapeControlView.viewController
            if let preVC = vc?.presentedViewController as? UIAlertController {
                vc?.dismiss(animated: false)
            }
            // 显示警告提示
            let alert = UIAlertController(
                title: "录屏已开启",
                message: "当前功能禁止屏幕录制",
                preferredStyle: .alert
            )
            vc?.present(alert, animated: false)
        }else{
            //竖屏
            let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .regular))
            blurView.frame = view.bounds
            blurView.tag = 10001
            view.addSubview(blurView)
            
            // 显示警告提示
            let alert = UIAlertController(
                title: "录屏已开启",
                message: "当前功能禁止屏幕录制",
                preferredStyle: .alert
            )
            present(alert, animated: false)
        }
        
    }

    // 移除保护层
    private func hidePrivacyProtection() {
        view.viewWithTag(10001)?.removeFromSuperview()
        self.controlView.landScapeControlView.viewWithTag(10001)?.removeFromSuperview()
        if let preVC = self.presentedViewController as? UIAlertController {
            self.dismiss(animated: false)
        }
        
        let vc = self.controlView.landScapeControlView.viewController
        if let preVC = vc?.presentedViewController as? UIAlertController {
            vc?.dismiss(animated: false)
        }
    }

    
    func configDataArray(){
        //配置数据
        let tempDataArray = NSMutableArray()
        //单集 简介
        if let vodPlayModel = self.vodPlayModel{//单集有值-简介
            for (_,mdl) in vodPlayModel.blockList.enumerated(){
                if mdl.type == "5"{//点播详情数据
                    //CNLiveVodPlayBlockListModel
                    tempDataArray.add(mdl)
                    self.vodPlayBlockListList5Model = mdl.list.first
                }
            }
        }
        //专辑-简介
//        if let vodAlbumListBaseModel = self.vodAlbumListBaseModel{//专辑有值-专辑列表
//            if let mdl = vodAlbumListBaseModel.list.first{
//                if let msgModel = mdl.vodAlbumMsgModel{
//                    let tempArr = NSMutableArray(array: tempDataArray as! [Any])
//                    if let vodMdl = tempArr.firstObject as? CNLiveVodPlayBlockListModel{
//                        for firMdl in vodMdl.list{
//                            firMdl.title = msgModel.albumName
//                            firMdl.desc = msgModel.desc
//                        }
//                        tempDataArray.removeAllObjects()
//                        tempDataArray.add(vodMdl)
//                    }
//                    
//                }
//            }
//        }
        //专辑有值-专辑列表
        if let vodAlbumListBaseModel = self.vodAlbumListBaseModel{//专辑有值-专辑列表
            tempDataArray.add(vodAlbumListBaseModel)
            self.albumListArr = NSMutableArray(array: vodAlbumListBaseModel.list)
        }
        //看点
        ///**blockList.type 1/2/3/4/5  商品入口/片花资讯/活动推荐/相关推荐/点播详情 */
        if let vodPlayModel = self.vodPlayModel{//单集有值-简介
            for (_,mdl) in vodPlayModel.blockList.enumerated(){
                if mdl.type == "2"{//看点list数据
                    //CNLiveVodPlayBlockListModel
                    tempDataArray.add(mdl)
                    self.kanDianListArr = NSMutableArray(array: mdl.list)
                }
            }
        }
        //商品
        if let vodPlayModel = self.vodPlayModel{//单集有值
            
            if vodPlayModel.goodsJson.count > 0{
                let goodMdls = jsonArrayToModel(vodPlayModel.goodsJson, CNLiveVodPlayShopModel.self)
                if goodMdls.count > 0{//CNLiveVodPlayModel [CNLiveVodPlayShopModel]
                    //有商品
                    tempDataArray.add(goodMdls)
                }else{
                    //没商品
                    self.getGoodBlockContents()
                }
            }else{
                //没商品
                self.getGoodBlockContents()
            }
        }
        
        self.dataArray = NSMutableArray(array: tempDataArray)

    }
    
    //只替换 点播详情数据 ,看点 专辑 电商 不替换
    func configDataArrayWithVodPlay5(vodPlayMdl : CNLiveVodPlayModel?){
        //配置数据
        let tempDataArray = NSMutableArray()
        //单集 简介
        var newVodPlayBlockListModel5:CNLiveVodPlayBlockListListModel?
        if let vodPlayModel = vodPlayMdl{//单集有值-简介
            for (_,mdl) in vodPlayModel.blockList.enumerated(){
                if mdl.type == "5"{//点播详情数据
                    newVodPlayBlockListModel5 = mdl.list.first
                }
            }
        }
        if let vodPlayModel = self.vodPlayModel{//单集有值-简介
            for (_,mdl) in vodPlayModel.blockList.enumerated(){
                if mdl.type == "5"{//点播详情数据
                    //CNLiveVodPlayBlockListModel
                    mdl.list[0] = newVodPlayBlockListModel5 ?? CNLiveVodPlayBlockListListModel()
                    tempDataArray.add(mdl)
                    self.vodPlayBlockListList5Model = newVodPlayBlockListModel5//mdl.list.first
                }
            }
        }
        //专辑-简介
        if let vodAlbumListBaseModel = self.vodAlbumListBaseModel{//专辑有值-专辑列表
            if let mdl = vodAlbumListBaseModel.list.first{
                if let msgModel = mdl.vodAlbumMsgModel{
                    let tempArr = NSMutableArray(array: tempDataArray as! [Any])
                    if let vodMdl = tempArr.firstObject as? CNLiveVodPlayBlockListModel{
                        for firMdl in vodMdl.list{
                            firMdl.title = msgModel.albumName
                            firMdl.desc = msgModel.desc
                        }
                        tempDataArray.removeAllObjects()
                        tempDataArray.add(vodMdl)
                    }
                    
                }
            }
        }
        //专辑有值-专辑列表
        if let vodAlbumListBaseModel = self.vodAlbumListBaseModel{//专辑有值-专辑列表
            tempDataArray.add(vodAlbumListBaseModel)
            self.albumListArr = NSMutableArray(array: vodAlbumListBaseModel.list)
        }
        //看点
        ///**blockList.type 1/2/3/4/5  商品入口/片花资讯/活动推荐/相关推荐/点播详情 */
        if let vodPlayModel = self.vodPlayModel{//单集有值-简介
            for (_,mdl) in vodPlayModel.blockList.enumerated(){
                if mdl.type == "2"{//看点list数据
                    //CNLiveVodPlayBlockListModel
                    tempDataArray.add(mdl)
                    self.kanDianListArr = NSMutableArray(array: mdl.list)
                }
            }
        }
        //商品
        if let vodPlayModel = self.vodPlayModel{//单集有值
            
            if vodPlayModel.goodsJson.count > 0{
                let goodMdls = jsonArrayToModel(vodPlayModel.goodsJson, CNLiveVodPlayShopModel.self)
                if goodMdls.count > 0{//CNLiveVodPlayModel [CNLiveVodPlayShopModel]
                    //有商品
                    tempDataArray.add(goodMdls)
                }else{
                    //没商品
                    self.getGoodBlockContents()
                }
            }else{
                //没商品
                self.getGoodBlockContents()
            }
        }
        
        self.dataArray = NSMutableArray(array: tempDataArray)

    }
    
    func setupNewUI(model:CNLiveDownSlideContentsModel){
        
    }
    
    //设置付费参数
    func setPayParams(payVodAlbumListModel:CNLiveVodAlbumListModel?,payContentId:String,payAid:String,payAlbumListArr:NSMutableArray,payIndex:Int,payTitle:String,payIsAlbum:Bool,payActivityId:String,isPayZhuanJi:Bool,payVodProductModel:CNLiveAlbumProductModel?){
        self.payVodAlbumListModel = payVodAlbumListModel
        self.payAid = payAid
        self.payContentId = payContentId
        self.payAlbumListArr = payAlbumListArr
        self.payIndex = payIndex
        self.payTitle = payTitle
        self.payIsAlbum = payIsAlbum
        self.payActivityId = payActivityId
        self.isPayZhuanJi = isPayZhuanJi
        self.payVodProductModel = payVodProductModel
        self.player.allowOrentitaionRotation = false
    }
    func resetPayParams(){
        //重置参数成功用pay参数
        self.payVodAlbumListModel = nil
        self.payAid = ""
        self.payContentId = ""
        self.payAlbumListArr = NSMutableArray()
        self.payIndex = 0
        self.payTitle = ""
        self.payIsAlbum = false
        self.payActivityId = ""
        self.player.allowOrentitaionRotation = true
    }
    // MARK: - 播放相关
    func setupPlayer(){
        let playerManager = ZFAVPlayerManager()
        playerManager.shouldAutoPlay = true
        
        player = CNLiveZFPlayerController(playerManager: playerManager, containerView: containerView)
        player.pauseWhenAppResignActive = false
        player.controlView = controlView
        //是否跟随设备旋转
        player.allowOrentitaionRotation = true
        
        self.player.orientationDidChanged = {[weak self] player,isFullScreen in
            guard let self = self else { return }
            self.handleScreenCaptureChange()

            
            if self.player.isFullScreen{
                
            }else{
                //横屏转竖屏时 ,隐藏横屏弹出的视图
                self.controlView.beiSuBgView.isHidden = true
                self.controlView.gaoqingBgView.isHidden = true
                self.controlView.xuanjiBgView.isHidden = true
            }
        }
        var endAssetURL:URL?
        /// 播放完成
        self.player.playerDidToEnd = {
            [weak self] asset in
            guard let self = self else { return }
            
            if endAssetURL == nil {
                endAssetURL = asset.assetURL
                self.playNextIfExist()
            }else{
                //一个视频回调 两次end
                endAssetURL = nil
            }
            let delayTime = DispatchTime.now()+3
            DispatchQueue.main.asyncAfter(deadline: delayTime) {
                endAssetURL = nil
            }
            //上报end
            CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1")
            print("\(self.contentId),\(self.vodPlayModel?.model)")
            
            //刷新选集-专辑列表
            if self.isPlayAblumOrKandian{
                self.controlView.xuanjiBgView.currSeleIdx = self.albumIndex
            }else{
                //刷新选集-看点列表
                self.controlView.xuanjiBgView.currSeleIdx = self.kanDianIndex
                self.controlView.xuanjiBgView.kandianTableView.reloadData()
            }
            
            
        }
        // MARK: - 横屏-选集-看点 点击某集
        self.controlView.xuanjiBgView.vodPlayerLandscapeXuanjiKanDianSelectBlock = { [weak self] seleIndex,vodPlayBlockListListModel in
            guard let self = self else { return }
            //切换横屏看点视频
            self.contentId = vodPlayBlockListListModel.contentId
            var isAblumVideo = false
            if vodPlayBlockListListModel.album?.albumId.count ?? 0 > 0{
                isAblumVideo = true
            }else{
                isAblumVideo = false
            }
            self.isPlayAblumOrKandian = false
            self.kanDianIndex = seleIndex
            self.albumIndex = -1
//            self.kanDianOrAlbumChangeContentApi(contentId: vodPlayBlockListListModel.contentId, title: vodPlayBlockListListModel.title, isAlbum: isAblumVideo, activeId: vodPlayBlockListListModel.pid, isRefreshPlayer:true )
                        
            let isPaid = CNLivePlayerTool.isPaid(product: vodPlayBlockListListModel.product)
            isPayZhuanJi = !isPaid
            
            var yuanString = "1"
            let fenString = vodPlayBlockListListModel.product?.iosRmb ?? "100"
            // 将字符串转换为整数
            let fen = Int(fenString) ?? 100
            // 计算元值(整数除法,自动舍去小数部分)
            var yuan = fen / 100
            // 将结果转换为字符串
            yuanString = String(yuan)
            self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: vodPlayBlockListListModel.product, mdlContentId: vodPlayBlockListListModel.contentId, isAblumVideo: false, albumSelectIndex: self.albumIndex, albumListArray: NSMutableArray(), kanDianSelectIndex: self.kanDianIndex, kanDianListArray: self.kanDianListArr, isPlayAblumOrKandian: false, xuanjiBgViewCurrSeleIdx: self.kanDianIndex, xuanjiBgViewKanDianListArr: self.kanDianListArr, modelTitle: vodPlayBlockListListModel.title, mdlActiveId: vodPlayBlockListListModel.pid, mdlModel: vodPlayBlockListListModel.model, yuanString: yuanString, payVodAlbumListModel: nil, vodAlbumListBaseModel: nil)

            
        }
        
        //        var title = ""
        //        if let blockListModel =  self.vodPlayModel?.blockList.first as? CNLiveVodPlayBlockListModel{
        //            if let blockListListModel = blockListModel.list.first{
        //                title = blockListListModel.title
        //            }
        //        }
        var title = ""
        if self.vodPlayModel?.blockList.count ?? 0 > 0{
            for mdl in self.vodPlayModel!.blockList{
                if mdl.type == "5"{//详情
                    if mdl.list.count > 0{
                        let vodModel = mdl.list[0]
                        title = vodModel.title
                    }
                }
            }
        }
        
        //true当前播放的专辑 false看点
        let isAblumVideo = (self.vodPlayModel?.album?.albumId.count ?? 0 > 0) ? true : false

        var yuanString = ""
        let isPaid = CNLivePlayerTool.isPaid(product: self.vodPlayModel?.product)
        if isPaid{
            //需要付费
            self.currentPlayIsNeedPay = true
            if isAblumVideo{
                let payVodAlbumListModel = self.vodAlbumListBaseModel?.list.count ?? 0 > self.albumIndex ? self.vodAlbumListBaseModel?.list[self.albumIndex] : nil
                var payAlbumListArr = NSMutableArray()
                if self.vodAlbumListBaseModel?.list.count ?? 0 > 0{
                    payAlbumListArr = NSMutableArray(array: self.vodAlbumListBaseModel!.list)
                }
                self.setPayParams(payVodAlbumListModel: payVodAlbumListModel, payContentId: self.vodPlayModel?.cid ?? (self.vodPlayModel?.contentId ?? ""), payAid: self.vodPlayModel?.albumId ?? "", payAlbumListArr: payAlbumListArr, payIndex: self.albumIndex, payTitle: title, payIsAlbum: true, payActivityId: self.vodPlayModel?.contentId ?? "", isPayZhuanJi: !isPaid, payVodProductModel: self.vodPlayModel?.product)
            }else{
                self.setPayParams(payVodAlbumListModel: nil, payContentId: self.vodPlayModel?.cid ?? "", payAid: self.vodPlayModel?.albumId ?? "", payAlbumListArr: NSMutableArray(), payIndex: albumIndex, payTitle: title, payIsAlbum: false, payActivityId: self.vodPlayModel?.contentId ?? "", isPayZhuanJi: !isPaid, payVodProductModel: self.vodPlayModel?.product)
            }
            
            var urls = [URL]()
            urls.append(self.url!)
            self.player.assetURLs = urls
            self.player.playTheIndex(0)
            self.player.currentPlayerManager.pause()
            
            self.controlView.payBgView.isHidden = false
            isPayZhuanJi = !isPaid
            //分转元,没有小数点
            let fenString = self.vodPlayModel?.product!.iosRmb ?? "100"
            // 将字符串转换为整数
            // 使用guard语句确保字符串可以转换为整数
            guard let fen = Int(fenString) else {
                print("无法将字符串转换为整数")
                return
            }
            // 计算元值(整数除法,自动舍去小数部分)
            var yuan = fen / 100
            if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元
                yuan = 1
            }
            // 将结果转换为字符串
            yuanString = String(yuan)
        }else{
            //免费或者付过费了
            self.currentPlayIsNeedPay = false
            self.resetPayParams()
            self.controlView.payBgView.isHidden = true
            isPayZhuanJi = !isPaid
//            self.playWithUrlAndTitle(url: self.url!.absoluteString, title: title)
        }
        
        var vodAlbumListModel:CNLiveVodAlbumListModel?
        if self.albumListArr.count > 0{
            if let vodAlbumListMdl = self.albumListArr[self.albumIndex] as? CNLiveVodAlbumListModel{
                vodAlbumListModel = vodAlbumListMdl
            }
        }
        let xuanjiBgViewKanDianListArr = isAblumVideo ? (self.albumListArr.count > 0 ? self.albumListArr : self.kanDianListArr) : self.kanDianListArr
        self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: self.vodPlayModel?.product, mdlContentId: self.vodPlayModel?.cid ?? (self.vodPlayModel?.contentId ?? ""), isAblumVideo: isAblumVideo, albumSelectIndex: self.albumIndex, albumListArray: self.albumListArr, kanDianSelectIndex: self.kanDianIndex, kanDianListArray: self.kanDianListArr, isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: isAblumVideo ? self.albumIndex : self.kanDianIndex , xuanjiBgViewKanDianListArr: xuanjiBgViewKanDianListArr, modelTitle: title, mdlActiveId: self.vodPlayModel?.contentId ?? "", mdlModel: self.vodPlayModel?.model ?? "1", yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: self.vodAlbumListBaseModel)
        //mdlActiveId: self.vodPlayModel?.contentId
        
        
        
        //        let isPaid = CNLivePlayerTool.isPaid(product: self.vodPlayModel?.product)
        //        if isPaid{
        //            var yuanString = ""
        //            //需要付费
        //            self.controlView.payBgView.isHidden = false
        //            isPayZhuanJi = false
        //            var urls = [URL]()
        //            urls.append(self.url!)
        //            self.player.assetURLs = urls
        //            self.player.playTheIndex(0)
        //            self.player.currentPlayerManager.pause()
        //            //分转元,没有小数点
        //            let fenString = self.vodPlayModel!.product!.iosRmb
        //            // 将字符串转换为整数
        //            // 使用guard语句确保字符串可以转换为整数
        //            guard let fen = Int(fenString) else {
        //                print("无法将字符串转换为整数")
        //                return
        //            }
        //            // 计算元值(整数除法,自动舍去小数部分)
        //            var yuan = fen / 100
        //            if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元
        //                yuan = 1
        //            }
        //            // 将结果转换为字符串
        //            yuanString = String(yuan)
        //
        //            //true当前播放的专辑 false看点
        ////            let isAblumVideo = false// (model.album?.albumId.count ?? 0 > 0) ? true : false
        //            let isAblumVideo = (self.vodPlayModel?.album?.albumId.count ?? 0 > 0) ? true : false
        //            var vodAlbumListModel:CNLiveVodAlbumListModel?
        //            if self.albumListArr.count > 0{
        //                if let vodAlbumListMdl = self.albumListArr[0] as? CNLiveVodAlbumListModel{
        //                    vodAlbumListModel = vodAlbumListMdl
        //                }
        //            }
        //            self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: self.vodPlayModel?.product, mdlContentId: self.vodPlayModel?.contentId ?? "", isAblumVideo: isAblumVideo, albumSelectIndex: 0, albumListArray: albumListArr, kanDianSelectIndex: -1, kanDianListArray: NSMutableArray(), isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: 0, xuanjiBgViewKanDianListArr: NSMutableArray(), modelTitle: title, mdlActiveId: self.vodPlayModel?.contentId ?? "", mdlModel: self.vodPlayModel?.model ?? "", yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: self.vodAlbumListBaseModel)
        
        
        //            if isPayZhuanJi{
        //                //已经付费
        //                self.controlView.payBgView.isHidden = true
        //                self.contentId = self.vodPlayModel?.contentId ?? ""
        //                self.albumListArr = albumListArr
        //                self.albumIndex = 0
        //                self.kanDianIndex = -1
        //                self.isPlayAblumOrKandian = true
        //                self.kanDianOrAlbumChangeContentApi(contentId: self.vodPlayModel?.contentId ?? "", title: title, isAlbum: true, activeId: self.vodPlayModel?.contentId ?? "", isRefreshPlayer: true)
        //                self.player.allowOrentitaionRotation = true
        //            }else{
        //                //没付费
        //                //显示付费页面
        //                let vodMdl = CNLiveVodPlayModel()
        //                vodMdl.product = self.vodPlayModel?.product
        //                vodMdl.contentId = self.vodPlayModel?.contentId ?? ""
        //                vodMdl.model = self.vodPlayModel?.model ?? ""
        //                self.controlView.vodPlayModel = vodMdl
        //                self.controlView.payBgView.isHidden = false
        //                self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本专辑", for: .normal)
        //
        //                //成功用pay参数 刷新页面
        //                self.albumListArr = NSMutableArray(array: self.vodAlbumListBaseModel?.list ?? [CNLiveVodAlbumListModel]())
        //                if self.albumListArr.count > 0{
        //                    if let vodAlbumListModel = self.albumListArr[0] as? CNLiveVodAlbumListModel{
        //                        self.payVodAlbumListModel = vodAlbumListModel
        //                        self.payAid = vodAlbumListModel.albumId//.contentId
        //                        self.payContentId = vodAlbumListModel.contentId
        //                        self.payAlbumListArr = albumListArr
        //                        self.payIndex = 0
        //                        self.payTitle = title
        //                        self.payIsAlbum = true
        //                        self.payActivityId = vodAlbumListModel.activityId
        //                        self.player.allowOrentitaionRotation = false
        //
        //                        self.contentId = self.vodPlayModel?.contentId ?? ""
        //                        self.albumListArr = albumListArr
        //                        self.albumIndex = 0
        //                        self.kanDianIndex = -1
        //                        self.isPlayAblumOrKandian = true
        //                        self.kanDianOrAlbumChangeContentApi(contentId: self.vodPlayModel?.contentId ?? "", title: title, isAlbum: true, activeId: self.vodPlayModel?.contentId ?? "", isRefreshPlayer: false)
        //                    }
        //                }
        //            }
        
        
//        }else{
//            //免费
//            
//            self.controlView.payBgView.isHidden = true
//            isPayZhuanJi = true
//            self.playWithUrlAndTitle(url: self.url!.absoluteString, title: title)
//
////            var urls = [URL]()
////            urls.append(self.url!)
////            self.player.assetURLs = urls
////            self.player.playTheIndex(0)
//            
//        }
        
        self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
        self.playTitle = title
        self.controlView.vodPlayerPayBlock = {[weak self] vodPlayMdl in
            guard let self = self else { return }
            //支付按钮,拉起内购
            //成功用pay参数 刷新页面
            
            let orderId = CNLiveHomePageViewModel.generateTradeNumber()
            let notifyUrl = "http://apps.pay.cnlive.com/upappnotify/notify/orderForVideo"
            var fenString = "100"
            var prdId = ""
            var body = ""
            if self.payIsAlbum{
                //当前支付的专辑
                //分转元,没有小数点
                fenString = self.payVodAlbumListModel?.product?.iosRmb ?? "100"
                prdId = vodPlayMdl.product?.productId ?? ""//"com.cnlive.metaCode."+yuanString//"com.cnlive.metaCode."+"1"//+(viewcell.homeModel.albumMsgModel?.product?.iosRmb ?? "1")
                body = self.payVodAlbumListModel?.product?.productTitle ?? ""
            }else{
                //当前支付的单集
                //分转元,没有小数点
                fenString = self.payVodProductModel?.iosRmb ?? "100"
                prdId = self.payVodProductModel?.productId ?? ""//"com.cnlive.metaCode."+yuanString//"com.cnlive.metaCode."+"1"//+(viewcell.homeModel.albumMsgModel?.product?.iosRmb ?? "1")
                body = self.payVodProductModel?.productTitle ?? ""
            }
            
            // 将字符串转换为整数
            // 使用guard语句确保字符串可以转换为整数
            guard let fen = Int(fenString) else {
                print("无法将字符串转换为整数")
                return
            }
            // 计算元值(整数除法,自动舍去小数部分)
            var yuan = fen / 100
            if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元
                yuan = 1
            }
            // 将结果转换为字符串
            let yuanString = String(yuan)
            let total_fee = yuan*100
            let dataDic = NSMutableDictionary()
            dataDic.setValue(body, forKey: "body")
            dataDic.setValue(notifyUrl, forKey: "notify_url")
            dataDic.setValue(orderId, forKey: "orderId")
            dataDic.setValue(prdId, forKey: "prdId")
            dataDic.setValue(total_fee, forKey: "total_fee")

            //后台设置一个 com.cnlive.metaCode.new 1 3 78 其他com.cnlive.metaCode.2
    
            //苹果内购
            CNLivePayCostModule.showApplePayViw(withParamDict: dataDic as! [AnyHashable : Any], fromVC: currentViewController()!) {[weak self] result in
                guard let self = self else { return }
                hiddenLoading()
                if result == CNLivePayCostTypeResultSucc{
                    print("succ")
                    //刷新页面
                    self.contentId = self.payContentId
                    self.refreshVodData(isAblumVideo: self.payIsAlbum)
                    self.controlView.payBgView.isHidden = true
                    
                    //重置参数成功用pay参数
                    self.resetPayParams()
                }
                
            }


        }
        // MARK: - 横屏-选集-专辑 点击某集
        self.controlView.controlXuanjiUpdateBlock = { [weak self] index,albumModel in
            guard let self = self else { return }

            //test 考虑横屏时切换剧集 也loading
//            let hub = MBProgressHUD.showAdded(to: self.controlView.landScapeControlView, animated: true)//self.controlView
//            hub.mode = .indeterminate
//            hub.animationType = .fade
//            hub.contentColor = .white
//            hub.bezelView.color = .black
//            hub.bezelView.style = .solidColor
//            hub.label.textColor = .white
//            hub.label.text = "加载中"
            
            let vodModel = albumModel
            //横屏-点击专辑 剧集的某集按钮
            var yuanString = "1"
            let isPaid = CNLivePlayerTool.isPaid(product: vodModel.product)
            if isPaid{
                //需要付费
                self.controlView.payBgView.isHidden = false
                //分转元,没有小数点
                let fenString = vodModel.product!.iosRmb
                // 将字符串转换为整数
                // 使用guard语句确保字符串可以转换为整数
                guard let fen = Int(fenString) else {
                    print("无法将字符串转换为整数")
                    return
                }
                // 计算元值(整数除法,自动舍去小数部分)
                var yuan = fen / 100
                if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元
                    yuan = 1
                }
                // 将结果转换为字符串
                yuanString = String(yuan)

            }else{
                //免费或者付过费了
                self.controlView.payBgView.isHidden = true
            }
            isPayZhuanJi = !isPaid
            
            //true当前播放的专辑 false看点
            let isAblumVideo = true// (model.album?.albumId.count ?? 0 > 0) ? true : false
//                let isAblumVideo = (vodModel.albumId.count > 0) ? true : false
            var vodAlbumListModel:CNLiveVodAlbumListModel?
            if self.albumListArr.count > 0{
                if let vodAlbumListMdl = self.albumListArr[index] as? CNLiveVodAlbumListModel{
                    vodAlbumListModel = vodAlbumListMdl
                }
            }
            self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: vodModel.product, mdlContentId: vodModel.contentId, isAblumVideo: isAblumVideo, albumSelectIndex: index, albumListArray: albumListArr, kanDianSelectIndex: -1, kanDianListArray: NSMutableArray(), isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: 0, xuanjiBgViewKanDianListArr: NSMutableArray(), modelTitle: vodModel.title, mdlActiveId: vodModel.activityId, mdlModel: vodModel.modelId, yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: vodAlbumListBaseModel)
//            CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: albumModel.activityId) { result, status in
//                if status == .success{
//                    if let url = result as? String{
//                        self.playWithUrlAndTitle(url: url, title: title)
//                    }
//                }
//
//            }

        }
        // MARK: - 横屏-切换分辨率
        self.controlView.controlGaoqingUpdateBlock = { [weak self] gaoqing in
            guard let self = self else { return }
            //更新分辨率按钮对应文案
            self.updateGaoqingBtnTitle(gaoqing: gaoqing)
            
            //2024_30d7a67242dc48ee987235f5135ab30e
            CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: self.vodPlayModel?.contentId ?? "", rate: gaoqing) {[weak self] result, status in
                guard let self = self else { return }
                if status == .success{
                    if let url = result as? String{
                        self.seekPlayerWithUrlAndTitle(url: url, title: self.playTitle, seekTime: self.player.currentTime)
                    }
                }
            }
        }
    }
    
    //更新分辨率按钮对应文案 //标清 2 ,高清 3 ,超清 4
    func updateGaoqingBtnTitle(gaoqing:Int){
        var title = "高清"
        if gaoqing == 2 {
            title = "标清"
        }else if gaoqing == 3 {
            title = "高清"
        }else if gaoqing == 4 {
            title = "超清"
        }
        self.controlView.gaoqingBtn.setTitle(title, for: .normal)
    }
    
    func playNextIfExist(){
        
        if self.isAblumVideo && self.isPlayAblumOrKandian{
            //当前播放的是 专辑列表 ,播专辑列表下一条
            let nextIdx = self.albumIndex + 1
            if nextIdx < self.albumListArr.count{
                self.albumIndex = nextIdx
                if let albumModel = self.albumListArr[nextIdx] as? CNLiveVodAlbumListModel{
                    //播专辑列表下一条
                    self.contentId = albumModel.contentId
                    
                    let isPaid = CNLivePlayerTool.isPaid(product: albumModel.product)
                    isPayZhuanJi = !isPaid
                    
                    var yuanString = "1"
                    let fenString = albumModel.product?.iosRmb ?? "100"
                    // 将字符串转换为整数
                    let fen = Int(fenString) ?? 100
                    // 计算元值(整数除法,自动舍去小数部分)
                    var yuan = fen / 100
                    // 将结果转换为字符串
                    yuanString = String(yuan)
                    
                    var vodAlbumListBaseModel = CNLiveVodAlbumListBaseModel()
                    vodAlbumListBaseModel.list = self.albumListArr as! [CNLiveVodAlbumListModel]
                    self.selectKanDianOrAlbum(isPayZhuanJi:isPayZhuanJi , mdlProduct: albumModel.product, mdlContentId: albumModel.contentId, isAblumVideo: true, albumSelectIndex: self.albumIndex, albumListArray: self.albumListArr, kanDianSelectIndex: -1, kanDianListArray: NSMutableArray(), isPlayAblumOrKandian: true, xuanjiBgViewCurrSeleIdx: -1, xuanjiBgViewKanDianListArr: NSMutableArray(), modelTitle: albumModel.title, mdlActiveId: albumModel.activityId, mdlModel: albumModel.modelId, yuanString: yuanString, payVodAlbumListModel: albumModel, vodAlbumListBaseModel: vodAlbumListBaseModel)
//                    self.selectKanDianOrAlbum(isPayZhuanJi: false, mdlProduct: albumModel.product, mdlContentId: albumModel.contentId, isAblumVideo: false, albumSelectIndex: self.albumIndex, albumListArray: NSMutableArray(), kanDianSelectIndex: self.kanDianIndex, kanDianListArray: self.kanDianListArr, isPlayAblumOrKandian: false, xuanjiBgViewCurrSeleIdx: self.kanDianIndex, xuanjiBgViewKanDianListArr: self.kanDianListArr, modelTitle: albumModel.title, mdlActiveId: albumModel.pid, mdlModel: albumModel.model, yuanString: yuanString, payVodAlbumListModel: nil, vodAlbumListBaseModel: nil)

//                    self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: true, activeId: albumModel.activityId, isRefreshPlayer: true)
                    
//                    self.changeContentApi(vodModel: albumModel)
                }

            }else{
//                self.player.stop()
            }
            
        }else{
            //当前播放的是 看点列表 ,播看点列表下一条
            let nextIdx = self.kanDianIndex + 1
            if nextIdx < self.kanDianListArr.count{
                self.kanDianIndex = nextIdx
                self.albumIndex = -1
                if let albumModel = self.kanDianListArr[nextIdx] as? CNLiveVodPlayBlockListListModel{
                    //播列表下一条
                    //true当前播放的专辑 false看点
                    let isAblumVideo = false// (model.album?.albumId.count ?? 0 > 0) ? true : false
//                    let isAblumVideo = (albumModel.album?.albumId.count ?? 0 > 0) ? true : false
//                    if isAblumVideo{
                    
                    let isPaid = CNLivePlayerTool.isPaid(product: albumModel.product)
                    isPayZhuanJi = !isPaid

                    
                    var yuanString = "1"
                    let fenString = albumModel.product?.iosRmb ?? "100"
                    // 将字符串转换为整数
                    let fen = Int(fenString) ?? 100
                    // 计算元值(整数除法,自动舍去小数部分)
                    var yuan = fen / 100
                    // 将结果转换为字符串
                    yuanString = String(yuan)
                    self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: albumModel.product, mdlContentId: albumModel.contentId, isAblumVideo: false, albumSelectIndex: self.albumIndex, albumListArray: NSMutableArray(), kanDianSelectIndex: self.kanDianIndex, kanDianListArray: self.kanDianListArr, isPlayAblumOrKandian: false, xuanjiBgViewCurrSeleIdx: self.kanDianIndex, xuanjiBgViewKanDianListArr: self.kanDianListArr, modelTitle: albumModel.title, mdlActiveId: albumModel.pid, mdlModel: albumModel.model, yuanString: yuanString, payVodAlbumListModel: nil, vodAlbumListBaseModel: nil)
//                    self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: isAblumVideo, activeId: albumModel.pid, isRefreshPlayer: true)
                    
//                    }else{
//                        self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: isAblumVideo, activeId: albumModel.pid)
//                    }
//                    self.changeContentApi(vodModel: albumModel)
                }

            }else{
//                self.player.stop()
            }
        }
        //            if (!self.player.isLastAssetURL) {
        //                [self.player playTheNext];
        //                NSString *title = [NSString stringWithFormat:@"视频标题%zd",self.player.currentPlayIndex];
        //                [self.controlView showTitle:title coverURLString:kVideoCover fullScreenMode:ZFFullScreenModeLandscape];
        //            } else {
        //                [self.player stop];
        //            }

    }
    //播放url更换title
    func playWithUrlAndTitle(url:String,title:String){
        if self.isSeek{
        }else{
            self.controlView.gaoqingBgView.resetGaoqing()
        }
        self.controlView.payBgView.isHidden = true
        self.isSeek = false
        self.player.currentPlayerManager.rate = 1.0
        if self.contentId == self.player.contentId{
            self.playTitle = title
            self.url = URL(string: url)
            var urls = [URL]()
            urls.append(self.url!)
            self.player.assetURLs = urls
            self.player.playTheIndex(0)
            self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
        }
        //上报end
        CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1")
    }
    func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){
        self.isSeek = true
        self.playWithUrlAndTitle(url: url, title: title)
        self.player.seek(toTime: seekTime)
        
    }

    //单集 更换contentId内容 play接口刷新看点和电商
    func vodChangeContentApi(vodModel:CNLiveVodAlbumListModel){
        //刷新url
        CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: vodModel.activityId) {[weak self] result, status in
            guard let self = self else { return }
            if status == .success
            {
                if let url = result as? String{
                    self.playWithUrlAndTitle(url: url, title: vodModel.title)
                }
            }else{
                
            }
        }

        
        //play接口刷新 看点和电商
        CNLiveDownSlideTool.getVodPlayApi(contentId: vodModel.contentId) {[weak self] result, status in
            guard let self = self else { return }
            if status == .success{
                if let vodPlayModel = result as? CNLiveVodPlayModel{
                    self.vodPlayModel = vodPlayModel
                    self.controlView.vodPlayModel = vodPlayModel
                    self.configDataArray()
                    self.tableView.reloadData()
                }else{
                    
                }
            }else{
                
            }
        }

    }
    func destroyPlayer(){
        self.player.stop()
    }
    
    // MARK: - 专辑/看点 列表切换某集
    func kanDianOrAlbumChangeContentApi(contentId:String,title:String,isAlbum:Bool,activeId:String, isRefreshPlayer: Bool){
//        if isAlbum{
        self.changeContentApi(activityId: activeId, title: title, contentId: contentId, isRefreshPlayer: isRefreshPlayer)
//        }else{
//            self.kanDianChangeContentApi(contentId: contentId, title: title)
//        }
    }
    // MARK: - 看点列表切换某集 只刷新播放器和点赞收藏
//    func kanDianChangeContentApi(contentId:String,title:String){
//        self.isPlayAblumOrKandian = false
//        //刷新url
//        CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: contentId) {[weak self] result, status in
//            guard let self = self else { return }
//            if status == .success
//            {
//                if let url = result as? String{
//                    self.playWithUrlAndTitle(url: url, title: title)
//                    self.url = URL(string: url)
//                }
//            }else{
//                
//            }
//        }
//
//        //play接口刷新 看点和电商
//        CNLiveDownSlideTool.getVodPlayApi(contentId: contentId) {[weak self] result, status in
//            guard let self = self else { return }
//            if status == .success{
//                if let vodPlayModel = result as? CNLiveVodPlayModel{
////                    self.vodPlayModel = vodPlayModel
//                    //单集有值-简介
//                    var index = 0
//                    var isReplace = false
//                    var tempMdl:CNLiveVodPlayBlockListModel?
//                    for (idx,mdl) in self.dataArray.enumerated(){
//                        if var tempVodMdl = mdl as? CNLiveVodPlayBlockListModel{
//                            if tempVodMdl.type ==  "5"{//点播详情数据
//                                
//                                for (_,vodMdl) in vodPlayModel.blockList.enumerated(){
//                                    if vodMdl.type == "5"{
//                                        tempMdl = vodMdl
//                                        index = idx
//                                        isReplace = true
//                                    }
//                                }
//                            }
//                        }
//                    }
//                    if isReplace{
//                        self.dataArray.replaceObject(at: index, with: tempMdl as Any)
//                    }else{}
//                    self.controlView.vodPlayModel = vodPlayModel
//                    self.configDataArray()
//                    self.tableView.reloadData()
//                }else{
//                    
//                }
//            }else{
//                
//            }
//        }
//
//    }

    
    // MARK: -专辑/看点 列表切换某集 ,刷新看点和电商
    func changeContentApi(activityId:String,title:String,contentId:String,isRefreshPlayer:Bool){
        //play接口刷新 看点和电商  1350755
        showLoading(message: "")
        CNLiveDownSlideTool.getVodPlayApi(contentId: contentId) {[weak self] result, status in
            guard let self = self else { return }
            if status == .success{
                if var vodPlayModel = result as? CNLiveVodPlayModel{
//                    self.vodPlayModel = vodPlayModel
                    //单集有值-简介
                    var temp5Mdl:CNLiveVodPlayBlockListModel?
                    var temp2Mdl:CNLiveVodPlayBlockListModel?
                    
                    //新数据 查找新数据是否有2看点数据,没有插入
                    var isContain2Model = false
                    for (_,vodMdl) in vodPlayModel.blockList.enumerated(){
                        if vodMdl.type == "5"{
                            temp5Mdl = vodMdl
                        }
                        if vodMdl.type == "2"{
                            temp2Mdl = vodMdl
                            isContain2Model = true
                        }else{
                            
                        }
                    }
                    if !isContain2Model{
                        //增加2 block
                        var blockList2Model = CNLiveVodPlayBlockListModel()
                        blockList2Model.list = [CNLiveVodPlayBlockListListModel]()
                        blockList2Model.type = "2"
                        blockList2Model.name = "看点"
                        vodPlayModel.blockList.append(blockList2Model)
                    }else{
                        print("111")
                    }
                    var tempVodPlayModel = vodPlayModel
                    
                    //旧看点的model
                    var tempKandian2Mdl:CNLiveVodPlayBlockListModel?
                    for (_,vodMdl) in self.vodPlayModel!.blockList.enumerated(){
                        if vodMdl.type == "2"{
                            tempKandian2Mdl = vodMdl
                        }
                    }
                    
                    var vodTitle = ""
                    
                    for(index,vodModel) in tempVodPlayModel.blockList.enumerated(){
                        if self.isPlayAblumOrKandian{
                            //切换剧集时, 调用play接口, 更新片花列表和商品列表
                            if temp2Mdl != nil{
                                if vodModel.type == "2"{//更新片花
                                    tempVodPlayModel.blockList[index] = temp2Mdl!
                                }
                            }

                        }else{
                            //切换看点时, 调用play接口, 只更新商品列表
                            //替换看点列表为旧数据
                            if vodModel.type == "2"{
                                tempVodPlayModel.blockList[index] = tempKandian2Mdl ?? CNLiveVodPlayBlockListModel()
                            }
                        }
                        
                        //更新简介里的 点赞和收藏 简介
                        if temp5Mdl != nil{
                            if vodModel.type == "5"{
                                tempVodPlayModel.blockList[index] = temp5Mdl!
                                vodTitle = temp5Mdl!.list.first?.title ?? title
                            }
                        }
                    }
                    tempVodPlayModel.goodsJson = vodPlayModel.goodsJson
                    self.vodPlayModel = tempVodPlayModel
                    self.controlView.vodPlayModel = tempVodPlayModel

                    //刷新url 1955_71512cfbcd5b497580732b48e26d16d6
                    if isRefreshPlayer{
                        showLoading(message: "")
                        CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: activityId) {[weak self] result, status in
                            guard let self = self else { return }
                            hiddenLoading()
                            if status == .success
                            {
                                if let url = result as? String{
                                    print("2222222:selfContentId:\(self.contentId),playerCid:\(contentId),playerActiId:\(activityId),playerTitle:\(title),playUrl:\(url)")
                                    if self.contentId == contentId{
                                        self.player.contentId = contentId
                                        self.player.activityId = activityId
                                        self.player.title = vodTitle
                                        self.player.url = url
                                        
                                        self.playWithUrlAndTitle(url: url, title: vodTitle)
                                        self.url = URL(string: url)
                                        
                                    }else{
                                        print("2222222:vodPlayMdlCId:\(self.vodPlayModel?.cid),vodPlayMdlContentId:\(self.vodPlayModel?.contentId),currentPlayIsNeedPay:\(self.currentPlayIsNeedPay)")
                                        if self.currentPlayIsNeedPay{
                                            //需要付费
                                            self.controlView.payBgView.isHidden = false
                                        }else{
                                            //免费或者付过费了
                                            self.controlView.payBgView.isHidden = true
                                        }

                                    }
                                }
                            }else{
                                
                            }
                        }
                    }
                    
                    if self.isPlayAblumOrKandian{
                        //如果是专辑,更新albumIndex
                        for (idx,mdl) in self.albumListArr.enumerated(){
                            if let model = mdl as? CNLiveVodAlbumListModel{
                                if vodPlayModel.contentId == model.contentId || vodPlayModel.contentId == model.activityId{
                                    self.albumIndex = idx
                                    break
                                }
                            }
                        }
                    }
                    
                    self.configDataArray()
                    self.tableView.reloadData()
                }else{
                    
                }
            }else{
                
            }
        }
        
    }
    // MARK: - 专辑刷新整个页面
    func refreshVodData(isAblumVideo:Bool){
        print("重定向地址 ==payAid:\(self.payAid),payContentId:\(self.payContentId)")
        showLoading(message: "")
        CNLiveDownSlideTool.getVodData(contentId: self.payAid, isAblumVideo: isAblumVideo,seleContentId: self.payContentId) {[weak self] vodPlayModel, contentId,url, result, status  in
            guard let self = self else { return }
            hiddenLoading()
            if status == .success{
                self.vodPlayModel = vodPlayModel
                self.controlView.vodPlayModel = vodPlayModel
                self.contentId = contentId
                if let vodAlbumListBaseModel = result{
                    self.vodAlbumListBaseModel = vodAlbumListBaseModel
                }
                self.url = URL(string: url)
                self.configDataArray()
                self.albumIndex = self.payIndex
                self.tableView.mj_header?.endRefreshing()
                self.tableView.reloadData()
                var title = ""
                for (_,mdl) in vodPlayModel.blockList.enumerated(){
                    if mdl.type == "5" && mdl.list.count > 0 {//点播详情数据
                        //CNLiveVodPlayBlockListListModel
                        if let playMdl = mdl.list.first as? CNLiveVodPlayBlockListListModel{
                            title = playMdl.title
                        }
                    }
                }
                self.playWithUrlAndTitle(url: url, title: title)
            }else{
                
            }
        }
    }

    
    
    // MARK: - UITableViewDelegate
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.dataArray.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if let vodPlayBlockListModel = self.dataArray[indexPath.row] as? CNLiveVodPlayBlockListModel{
            if vodPlayBlockListModel.type == "5"{
                //点播详情
                //简介-标题描述,点赞评论分享
                guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodIntroductionCellIdentifier) as? CNLiveVodIntroductionCell
                else {
                    let cell = CNLiveVodIntroductionCell()
                    return cell
                }
                cell.vodPlayBlockListModel = vodPlayBlockListModel
                cell.updateCellBlock = {[weak self] isExpand,isFavorite,favoriteNum,isCollection,type,vodPlayBlockListListModel in
                    guard let self = self else { return }
                    if type == "1"{
                        //点击了详情按钮
                        self.introducCellDetailBtnAction(vodPlayBlockListListModel: vodPlayBlockListListModel)
                    }else if type == "2"{
                        //点击了点赞按钮
                        self.vodSupport(vodPlayBlockListListModel: vodPlayBlockListListModel, isLiked: isFavorite, favoriteNum: favoriteNum)
                    }else if type == "3"{
                        //点击了收藏按钮
                        self.vodCollection(vodPlayBlockListListModel: vodPlayBlockListListModel, isCollectioned: isCollection)
                    }else if type == "4"{
                        //点击了分享按钮
                        self.vodShare(vodPlayBlockListListModel: vodPlayBlockListListModel)
                    }
                }
                return cell

            }else if vodPlayBlockListModel.type == "2"{//看点
                //看点
                guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodTrailersCellIdentifier) as? CNLiveVodTrailersCell
                else {
                    let cell = CNLiveVodTrailersCell()
                    return cell
                }
                cell.currSeleIdx = self.kanDianIndex//-1
                cell.vodPlayBlockListModel = vodPlayBlockListModel
                ////看点展开
                cell.expandBlock = { [weak self] model in
                    guard let self = self else { return }
                    self.trailersCellDetailBtnAction(vodPlayBlockListModel: model)
                }
                ////看点点击
                cell.selectBlock = { [weak self] model,index,kanDianListArr in
                    guard let self = self else { return }
                    //点击看点
                    self.player.currentPlayerManager.pause()
                    var yuanString = "1"

                    let isPaid = CNLivePlayerTool.isPaid(product: model.product)
                    if isPaid{
                        //需要付费
                        self.controlView.payBgView.isHidden = false
                        isPayZhuanJi = !isPaid
                        //分转元,没有小数点
                        let fenString = model.product!.iosRmb
                        // 将字符串转换为整数
                        // 使用guard语句确保字符串可以转换为整数
                        guard let fen = Int(fenString) else {
                            print("无法将字符串转换为整数")
                            return
                        }
                        // 计算元值(整数除法,自动舍去小数部分)
                        var yuan = fen / 100
                        if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元
                            yuan = 1
                        }
                        // 将结果转换为字符串
                        yuanString = String(yuan)
                    }else{
                        //免费或者付过费了
                        self.controlView.payBgView.isHidden = true
                        isPayZhuanJi = !isPaid
                    }
                    
                    //true当前播放的专辑 false看点
                    let isAblumVideo = false// (model.album?.albumId.count ?? 0 > 0) ? true : false
                    var vodAlbumListModel:CNLiveVodAlbumListModel?
                    if self.albumListArr.count > 0{
                        if let vodAlbumListMdl = self.albumListArr[index] as? CNLiveVodAlbumListModel{
                            vodAlbumListModel = vodAlbumListMdl
                        }
                    }
                    self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: model.product, mdlContentId: model.contentId, isAblumVideo: isAblumVideo, albumSelectIndex: -1, albumListArray: NSMutableArray(), kanDianSelectIndex: index, kanDianListArray: kanDianListArr, isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: index, xuanjiBgViewKanDianListArr: kanDianListArr, modelTitle: model.title, mdlActiveId: model.pid, mdlModel: model.model, yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: nil)

                    
//                    if isPayZhuanJi{
//                        //已经付费
//                        self.controlView.payBgView.isHidden = true
//
//                        self.contentId = model.contentId
//                        let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false
//                        self.albumIndex = -1
//                        self.kanDianIndex = index
//                        self.kanDianListArr = kanDianListArr
//                        //只更新 此视频的长id,换url(不管是不是专辑)
//                        self.isPlayAblumOrKandian = false
//                        //更新选集-看点列表
//                        //kanDianListArr cnLivevodPlayBlocjListlistModel
//                        self.controlView.xuanjiBgView.currSeleIdx = index
//                        self.controlView.xuanjiBgView.kanDianListArr = kanDianListArr
//                        self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid, isRefreshPlayer:true )
//                        self.player.allowOrentitaionRotation = true
//                    }else{
//                        //没付费
//                        //显示付费页面
//                        let vodMdl = CNLiveVodPlayModel()
//                        vodMdl.product = model.product
//                        vodMdl.contentId = model.contentId
//                        vodMdl.model = model.model
//                        self.controlView.vodPlayModel = vodMdl
//                        self.controlView.payBgView.isHidden = false
//                        self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本集内容", for: .normal)
//                        
//                        self.contentId = model.contentId
//                        let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false
//                        self.albumIndex = -1
//                        self.kanDianIndex = index
//                        self.kanDianListArr = kanDianListArr
//                        self.isPlayAblumOrKandian = false
//
//                        //成功用pay参数 刷新页面
//                        self.payVodProductModel = model.product
//                        self.payContentId = model.contentId
//                        self.payIndex = -1
//                        self.payTitle = model.title
//                        self.payIsAlbum = false
//                        self.payActivityId = model.pid
//                        self.player.allowOrentitaionRotation = false
//                        self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid, isRefreshPlayer:false )
//                    }
                }
                return cell
            }else{
                
            }
        }else if let vodAlbumListBaseModel = self.dataArray[indexPath.row] as? CNLiveVodAlbumListBaseModel{
            //专辑列表
            guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodAlbumListCellIdentifier) as? CNLiveVodAlbumListCell
            else {
                let cell = CNLiveVodAlbumListCell()
                return cell
            }
            cell.currSeleIdx = self.albumIndex
            cell.vodAlbumListBaseModel = vodAlbumListBaseModel
            if self.isPlayAblumOrKandian{
                //播放的专辑
                self.controlView.xuanjiBgView.currSeleIdx = self.albumIndex
                self.controlView.xuanjiBgView.vodAlbumListBaseModel = vodAlbumListBaseModel
            }else{
                //播放的看点
//                self.controlView.xuanjiBgView.currSeleIdx = self.kanDianIndex
//                self.controlView.xuanjiBgView.kanDianListArr = self.kanDianListArr
                //CNLiveVodPlayblockListListModel
            }
            //点击专辑
            cell.selectBlock = {[weak self] vodModel, index ,albumListArr,vodAlbumListBaseModel in
                guard let self = self else { return }
                var yuanString = "1"
                let isPaid = CNLivePlayerTool.isPaid(product: vodModel.product)
                if isPaid{
                    //需要付费
                    self.controlView.payBgView.isHidden = false
                    //分转元,没有小数点
                    let fenString = vodModel.product!.iosRmb
                    // 将字符串转换为整数
                    // 使用guard语句确保字符串可以转换为整数
                    guard let fen = Int(fenString) else {
                        print("无法将字符串转换为整数")
                        return
                    }
                    // 计算元值(整数除法,自动舍去小数部分)
                    var yuan = fen / 100
                    if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元
                        yuan = 1
                    }
                    // 将结果转换为字符串
                    yuanString = String(yuan)

                }else{
                    //免费或者付过费了
                    self.controlView.payBgView.isHidden = true
                }
                isPayZhuanJi = !isPaid
                
                //true当前播放的专辑 false看点
                let isAblumVideo = true// (model.album?.albumId.count ?? 0 > 0) ? true : false
//                let isAblumVideo = (vodModel.albumId.count > 0) ? true : false
                var vodAlbumListModel:CNLiveVodAlbumListModel?
                if self.albumListArr.count > 0{
                    if let vodAlbumListMdl = self.albumListArr[index] as? CNLiveVodAlbumListModel{
                        vodAlbumListModel = vodAlbumListMdl
                    }
                }
                self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: vodModel.product, mdlContentId: vodModel.contentId, isAblumVideo: isAblumVideo, albumSelectIndex: index, albumListArray: albumListArr, kanDianSelectIndex: -1, kanDianListArray: NSMutableArray(), isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: 0, xuanjiBgViewKanDianListArr: NSMutableArray(), modelTitle: vodModel.title, mdlActiveId: vodModel.activityId, mdlModel: vodModel.modelId, yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: vodAlbumListBaseModel)

//                if isPayZhuanJi{
//                    //已经付费
//                    self.controlView.payBgView.isHidden = true
//                    self.contentId = vodModel.contentId
//                    self.albumListArr = albumListArr
//                    self.albumIndex = index
//                    self.kanDianIndex = -1
//                    self.isPlayAblumOrKandian = true
//                    self.kanDianOrAlbumChangeContentApi(contentId: vodModel.contentId, title: vodModel.title, isAlbum: true, activeId: vodModel.activityId, isRefreshPlayer: true)
//                    self.player.allowOrentitaionRotation = true
//                }else{
//                    //没付费
//                    //显示付费页面
//                    let vodMdl = CNLiveVodPlayModel()
//                    vodMdl.product = vodModel.product
//                    vodMdl.contentId = vodModel.contentId
//                    vodMdl.model = vodModel.modelId
//                    self.controlView.vodPlayModel = vodMdl
//                    self.controlView.payBgView.isHidden = false
//                    self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本专辑", for: .normal)
//                    
//                    self.contentId = vodModel.contentId
//                    self.albumListArr = albumListArr
//                    self.albumIndex = index
//                    self.kanDianIndex = -1
//                    self.isPlayAblumOrKandian = true
//                    
//                    //成功用pay参数 刷新页面
//                    self.payVodAlbumListModel = vodModel
//                    self.payAid = vodModel.albumId//.contentId
//                    self.payContentId = vodModel.contentId
//                    self.payAlbumListArr = albumListArr
//                    self.payIndex = index
//                    self.payTitle = vodModel.title
//                    self.payIsAlbum = true
//                    self.payActivityId = vodModel.activityId
//                    self.player.allowOrentitaionRotation = false
//                    self.kanDianOrAlbumChangeContentApi(contentId: vodModel.contentId, title: vodModel.title, isAlbum: true, activeId: vodModel.activityId, isRefreshPlayer: false)
//                }
            }
            return cell
        }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveVodPlayShopModel]{
            //电商
            guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodPlayShopCellIdentifier) as? CNLiveVodPlayShopCell
            else {
                let cell = CNLiveVodPlayShopCell()
                return cell
            }
            cell.vodPlayShopModels = vodPlayShopModels
            cell.expandBlock = {[weak self] vodPlayShopModels in
                guard let self = self else { return }
                self.shopCellDetailBtnAction(vodPlayShopModels: vodPlayShopModels as? [CNLiveVodPlayShopModel], albumModels: nil)
            }
            return cell
        }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveAlbumModel]{
            //默认电商商品
            guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVodPlayShopCellIdentifier) as? CNLiveVodPlayShopCell
            else {
                let cell = CNLiveVodPlayShopCell()
                return cell
            }
            cell.albumModels = vodPlayShopModels
            cell.expandBlock = {[weak self] vodPlayShopModels in
                guard let self = self else { return }
                self.shopCellDetailBtnAction(vodPlayShopModels: nil, albumModels: vodPlayShopModels as? [CNLiveAlbumModel])
            }
            return cell
        }else {
            return UITableViewCell()
        }
        
        return UITableViewCell()
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if let vodPlayBlockListModel = self.dataArray[indexPath.row] as? CNLiveVodPlayBlockListModel{
            if vodPlayBlockListModel.type == "5"{
                //点播详情
                //简介-标题描述,点赞评论分享
                return 112
            }else if vodPlayBlockListModel.type == "2"{
                //看点
                return 25+106+76
            }else{
            }
    
        }else if let vodAlbumListBaseModel = self.dataArray[indexPath.row] as? CNLiveVodAlbumListBaseModel{
            //专辑列表
            return 50+15
        }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveVodPlayShopModel]{
            //电商
            return 145.0
        }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveAlbumModel]{
            //默认电商
            return 145.0
        }else {
            
        }
        return 100
    }
    
    func addRefreshView() {
        tableView.mj_header = MJRefreshNormalHeader.init(refreshingBlock: {[weak self] in
            guard let self = self else { return }
            self.refreshVodData(isAblumVideo: self.isAblumVideo)
        })
    }
            
    override var preferredStatusBarStyle: UIStatusBarStyle{
        return .lightContent
    }
    
    override var prefersStatusBarHidden: Bool{
        return false
    }
    
    override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation{
        return .none
    }
    
    override var shouldAutorotate: Bool{
        return false
    }

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
        return .allButUpsideDown
    }

    //电商商品展开
    func shopCellDetailBtnAction(vodPlayShopModels:[CNLiveVodPlayShopModel]?,albumModels:[CNLiveAlbumModel]?) {
        bottomCommentShowContainView.isHidden = false
        
        let detailBgView = CNLiveVodShopBottomView(frame: bottomCommentShowContainView.bounds)
        detailBgView.backgroundColor = .white
        bottomCommentShowContainView.addSubview(detailBgView)
        if vodPlayShopModels?.count ?? 0 > 0{
            detailBgView.vodPlayShopModels = vodPlayShopModels
        }
        if albumModels?.count ?? 0 > 0{
            detailBgView.albumModels = albumModels
        }
        detailBgView.expandHideBlock = {[weak self] in
            guard let self = self else { return }
            self.bottomCommentShowContainView.removeAllSubviews()
            self.bottomCommentShowContainView.isHidden = true
        }
        
    }
    // MARK: - 点击 看点/专辑
    //isAblumVideo true:播放或选择的专辑 false:看点
    func selectKanDianOrAlbum(isPayZhuanJi:Bool,mdlProduct:CNLiveAlbumProductModel?,mdlContentId:String,isAblumVideo:Bool,albumSelectIndex:Int,albumListArray:NSMutableArray,kanDianSelectIndex:Int,kanDianListArray: NSMutableArray,isPlayAblumOrKandian:Bool,xuanjiBgViewCurrSeleIdx:Int,xuanjiBgViewKanDianListArr:NSMutableArray,modelTitle:String,mdlActiveId:String,mdlModel:String,yuanString:String,payVodAlbumListModel:CNLiveVodAlbumListModel?,vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel?){
        self.player.currentPlayerManager.pause()
        if isPayZhuanJi{
            //已付费
            self.currentPlayIsNeedPay = false
            if isAblumVideo{
                //点击专辑
                self.controlView.payBgView.isHidden = isPayZhuanJi
                self.contentId = mdlContentId
                self.albumListArr = albumListArray
                self.albumIndex = albumSelectIndex
                self.kanDianIndex = kanDianSelectIndex
                self.isPlayAblumOrKandian = isPlayAblumOrKandian
                //更新选集-专辑列表
                self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx
                self.controlView.xuanjiBgView.vodAlbumListBaseModel = vodAlbumListBaseModel
                self.kanDianOrAlbumChangeContentApi(contentId: mdlContentId, title: modelTitle, isAlbum: isAblumVideo, activeId: mdlActiveId, isRefreshPlayer: isPayZhuanJi)
                self.player.allowOrentitaionRotation = isPayZhuanJi
            }else{
                //点击看点
                self.controlView.payBgView.isHidden = isPayZhuanJi
                self.contentId = mdlContentId
                self.albumIndex = albumSelectIndex
                self.albumListArr = albumListArray
                self.kanDianIndex = kanDianSelectIndex
                self.kanDianListArr = kanDianListArray
                //只更新 此视频的长id,换url(不管是不是专辑)
                self.isPlayAblumOrKandian = isPlayAblumOrKandian
                //更新选集-看点列表
                self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx
                self.controlView.xuanjiBgView.kanDianListArr = kanDianListArray
                self.kanDianOrAlbumChangeContentApi(contentId: mdlContentId, title: modelTitle, isAlbum: isAblumVideo, activeId: mdlActiveId, isRefreshPlayer:isPayZhuanJi)
                self.player.allowOrentitaionRotation = isPayZhuanJi
            }
        }else{
            //未付费
            self.player.currentPlayerManager.pause()
            self.player.enterFullScreen(false, animated: false)
            
            self.currentPlayIsNeedPay = true
            if isAblumVideo{
                //点击专辑
                //显示付费页面
                let vodMdl = CNLiveVodPlayModel()
                vodMdl.product = mdlProduct
                vodMdl.contentId = mdlContentId
                vodMdl.model = mdlModel
                self.controlView.vodPlayModel = vodMdl
                self.controlView.payBgView.isHidden = isPayZhuanJi
                self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本专辑", for: .normal)
                
                self.contentId = mdlContentId
                self.albumListArr = albumListArray
                self.albumIndex = albumSelectIndex
                self.kanDianIndex = kanDianSelectIndex
                self.isPlayAblumOrKandian = isPlayAblumOrKandian
                
                //成功用pay参数 刷新页面
                self.setPayParams(payVodAlbumListModel: payVodAlbumListModel, payContentId: payVodAlbumListModel?.contentId ?? "", payAid: payVodAlbumListModel?.albumId ?? "", payAlbumListArr: albumListArray, payIndex: albumSelectIndex, payTitle: modelTitle, payIsAlbum: isAblumVideo, payActivityId: mdlActiveId, isPayZhuanJi: isPayZhuanJi, payVodProductModel: mdlProduct)
                
//                self.player.allowOrentitaionRotation = true//test
//                self.resetPayParams()//test
//                self.controlView.payBgView.isHidden = true
                
//                //成功用pay参数 刷新页面
//                self.payVodAlbumListModel = payVodAlbumListModel
//                self.payAid = payVodAlbumListModel?.albumId ?? ""
//                self.payContentId = payVodAlbumListModel?.contentId ?? ""
//                self.payAlbumListArr = albumListArray
//                self.payIndex = albumSelectIndex
//                self.payTitle = modelTitle
//                self.payIsAlbum = isAblumVideo
//                self.payActivityId = mdlActiveId
//                self.player.allowOrentitaionRotation = isPayZhuanJi
                
                //更新选集-专辑列表
                self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx
                self.controlView.xuanjiBgView.vodAlbumListBaseModel = vodAlbumListBaseModel
                self.kanDianOrAlbumChangeContentApi(contentId: mdlContentId, title: modelTitle, isAlbum: isAblumVideo, activeId: mdlActiveId, isRefreshPlayer: isPayZhuanJi)
            }else{
                //点击看点
                let vodMdl = CNLiveVodPlayModel()
                vodMdl.product = mdlProduct
                vodMdl.contentId = mdlContentId
                vodMdl.model = mdlModel
                self.controlView.vodPlayModel = vodMdl
                self.controlView.payBgView.isHidden = false
                self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本内容", for: .normal)
                
                self.contentId = mdlContentId
                self.albumIndex = albumSelectIndex
                self.kanDianIndex = kanDianSelectIndex
                self.kanDianListArr = kanDianListArray
                self.isPlayAblumOrKandian = isPlayAblumOrKandian

                //成功用pay参数 刷新页面
                self.setPayParams(payVodAlbumListModel: nil, payContentId: mdlContentId, payAid: "", payAlbumListArr: NSMutableArray(), payIndex: albumSelectIndex, payTitle: modelTitle, payIsAlbum: isAblumVideo, payActivityId: mdlActiveId, isPayZhuanJi: isPayZhuanJi, payVodProductModel: mdlProduct)
//                self.payVodProductModel = mdlProduct
//                self.payContentId = mdlContentId
//                self.payIndex = albumSelectIndex
//                self.payTitle = modelTitle
//                self.payIsAlbum = isAblumVideo
//                self.payActivityId = mdlActiveId
//                self.player.allowOrentitaionRotation = isPayZhuanJi
                //更新选集-看点列表
                self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx
                self.controlView.xuanjiBgView.kanDianListArr = kanDianListArray
                self.kanDianOrAlbumChangeContentApi(contentId: mdlContentId, title: modelTitle, isAlbum: isAblumVideo, activeId: mdlActiveId, isRefreshPlayer:isPayZhuanJi)
            }
        }
    }
    
    // MARK: - 看点cell展开
    func trailersCellDetailBtnAction(vodPlayBlockListModel:CNLiveVodPlayBlockListModel) {
        bottomCommentShowContainView.isHidden = false
        
        let detailBgView = CNLiveVodCellBottomView(frame: bottomCommentShowContainView.bounds)
        detailBgView.backgroundColor = .white
        bottomCommentShowContainView.addSubview(detailBgView)
        detailBgView.selectIdx = self.kanDianIndex
        detailBgView.vodPlayBlockListModel = vodPlayBlockListModel
        detailBgView.expandHideBlock = {[weak self] in
            guard let self = self else { return }
            self.bottomCommentShowContainView.removeAllSubviews()
            self.bottomCommentShowContainView.isHidden = true
        }
        detailBgView.updateBlock = {[weak self] seleIdx,model,kanDianListArr in
            guard let self = self else { return }
            self.player.currentPlayerManager.pause()
            var yuanString = "1"

            let isPaid = CNLivePlayerTool.isPaid(product: model.product)
            if isPaid{
                //需要付费
                self.controlView.payBgView.isHidden = false
                //分转元,没有小数点
                let fenString = model.product!.iosRmb
                // 将字符串转换为整数
                // 使用guard语句确保字符串可以转换为整数
                guard let fen = Int(fenString) else {
                    print("无法将字符串转换为整数")
                    return
                }
                // 计算元值(整数除法,自动舍去小数部分)
                var yuan = fen / 100
                if yuan <= 0{//如果是测试0.1元 ,线上默认设置为1元
                    yuan = 1
                }
                // 将结果转换为字符串
                yuanString = String(yuan)
            }else{
                //免费或者付过费了
                self.controlView.payBgView.isHidden = true
            }
            isPayZhuanJi = !isPaid
//            let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false
//            self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: model.product, mdlContentId: model.contentId, isAblumVideo: isAblumVideo, albumSelectIndex: -1, kanDianSelectIndex: seleIdx, kanDianListArray: kanDianListArr, isPlayAblumOrKandian: false, xuanjiBgViewCurrSeleIdx: seleIdx, xuanjiBgViewKanDianListArr: kanDianListArr, modelTitle: model.title, mdlActiveId: model.pid, mdlModel: model.model, yuanString: yuanString)
            
            //true当前播放的专辑 false看点
            let isAblumVideo = false// (model.album?.albumId.count ?? 0 > 0) ? true : false
//            let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false
            var vodAlbumListModel:CNLiveVodAlbumListModel?
            if self.albumListArr.count > 0{
                if let vodAlbumListMdl = self.albumListArr[seleIdx] as? CNLiveVodAlbumListModel{
                    vodAlbumListModel = vodAlbumListMdl
                }
            }
            self.selectKanDianOrAlbum(isPayZhuanJi: isPayZhuanJi, mdlProduct: model.product, mdlContentId: model.contentId, isAblumVideo: isAblumVideo, albumSelectIndex: -1, albumListArray: NSMutableArray(), kanDianSelectIndex: seleIdx, kanDianListArray: kanDianListArr, isPlayAblumOrKandian: isAblumVideo, xuanjiBgViewCurrSeleIdx: seleIdx, xuanjiBgViewKanDianListArr: kanDianListArr, modelTitle: model.title, mdlActiveId: model.pid, mdlModel: model.model, yuanString: yuanString, payVodAlbumListModel: vodAlbumListModel, vodAlbumListBaseModel: nil)

//            if isPayZhuanJi{
//                //已经付费
//                self.controlView.payBgView.isHidden = true
//
//                self.contentId = model.contentId
//                let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false
//                self.albumIndex = -1
//                self.kanDianIndex = seleIdx
//                self.kanDianListArr = kanDianListArr
//                //只更新 此视频的长id,换url(不管是不是专辑)
//                self.isPlayAblumOrKandian = false
//                //更新选集-看点列表
//                //kanDianListArr cnLivevodPlayBlocjListlistModel
//                self.controlView.xuanjiBgView.currSeleIdx = seleIdx
//                self.controlView.xuanjiBgView.kanDianListArr = kanDianListArr
//                self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid, isRefreshPlayer:true )
//                self.player.allowOrentitaionRotation = true
//            }else{
//                //没付费
//                //显示付费页面
//                let vodMdl = CNLiveVodPlayModel()
//                vodMdl.product = model.product
//                vodMdl.contentId = model.contentId
//                vodMdl.model = model.model
//                self.controlView.vodPlayModel = vodMdl
//                self.controlView.payBgView.isHidden = false
//                self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本集内容", for: .normal)
//                //成功用pay参数 刷新页面
//                self.payVodProductModel = model.product
//                self.payContentId = model.contentId
//                self.payIndex = -1
//                self.kanDianIndex = seleIdx
//                self.isPlayAblumOrKandian = false
//                self.payTitle = model.title
//                self.payIsAlbum = false
//                self.payActivityId = model.pid
//                self.player.allowOrentitaionRotation = false
//            }

            
            
            
//            self.contentId = model.contentId
//            var isAblumVideo = false
//            if model.album?.albumId.count ?? 0 > 0{
//                isAblumVideo = true
//            }else{
//                isAblumVideo = false
//            }
//            self.albumIndex = -1
//            self.kanDianIndex = seleIdx
//            self.kanDianListArr = kanDianListArr
//            //只更新 此视频的长id,换url(不管是不是专辑)
//            self.isPlayAblumOrKandian = false
//            //更新选集-看点列表
//            //kanDianListArr cnLivevodPlayBlocjListlistModel
//            self.controlView.xuanjiBgView.currSeleIdx = seleIdx
//            self.controlView.xuanjiBgView.kanDianListArr = kanDianListArr
//
//            self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid, isRefreshPlayer: )
        }
    }
    // MARK: - 简介cell点击事件
    func introducCellDetailBtnAction(vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel) {
        bottomCommentShowContainView.isHidden = false
        
        let detailBgView = UIView(frame: bottomCommentShowContainView.bounds)
        detailBgView.backgroundColor = .white
        bottomCommentShowContainView.addSubview(detailBgView)
        
        let vodMdl = vodPlayBlockListListModel

        let titleLbl = UILabel()
        titleLbl.font = BoldFont_15
        titleLbl.textColor = HexColor("#000102")
        titleLbl.text = vodMdl.title
        bottomCommentShowContainView.addSubview(titleLbl)
        
        titleLbl.snp.makeConstraints { make in
            make.left.equalTo(10)
            make.top.equalTo(16)
            make.width.lessThanOrEqualTo(KSreenWidth-50)
        }
        
        let detailLbl = UILabel()
        detailLbl.font = Font_10
        detailLbl.textColor = HexColor("#999999")
        detailLbl.text = "详情"
        bottomCommentShowContainView.addSubview(detailLbl)
        detailLbl.snp.makeConstraints { make in
            make.left.equalTo(titleLbl.snp.right).offset(15)
            make.top.equalTo(20.5)
            make.width.equalTo(21)
            make.height.equalTo(14)
        }

        let descLbl = UITextView()
        descLbl.font = Font_13
        descLbl.backgroundColor = .white
        descLbl.textColor = HexColor("#999999")
        descLbl.text = vodMdl.desc
        descLbl.width = KSreenWidth-20
        descLbl.isUserInteractionEnabled = false
        bottomCommentShowContainView.addSubview(descLbl)

        descLbl.snp.makeConstraints { make in
            make.left.equalTo(10)
            make.top.equalTo(titleLbl.snp.bottom).offset(10)
            make.right.equalToSuperview().offset(-20)
            make.bottom.equalToSuperview().offset(-15-50-10)
        }
        
        let expandBtn = UIButton.init(type: .custom)
        expandBtn.backgroundColor = .clear
        expandBtn.setImage(UIImage(named: "home_player_unexpand"), for: .normal)
        expandBtn.addTarget(self, action: #selector(expandBtnAction), for: .touchUpInside)
        bottomCommentShowContainView.addSubview(expandBtn)
        expandBtn.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-15)
            make.width.equalTo(50)
            make.height.equalTo(50)
        }
        
    }

    // MARK: -点赞/收藏 刷新数据 不刷新看点列表 专辑列表
    func getVodPlayApi(contentId:String){
        //play接口刷新 看点和电商  1350755
        showLoading(message: "")
        CNLiveDownSlideTool.getVodPlayApi(contentId: contentId) {[weak self] result, status in
            guard let self = self else { return }
            if status == .success{
                if let vodPlayModel = result as? CNLiveVodPlayModel{
                    self.configDataArrayWithVodPlay5(vodPlayMdl: vodPlayModel)
                    self.tableView.reloadData()
                }
            }
        }
    }
    func vodSupport(vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel,isLiked:Bool,favoriteNum:Int){
        if metaAppDelegate.isLogin{
            CNLiveVodPlayViewModel.vodSupport(contentId: vodPlayBlockListListModel.pid, support: isLiked) {[weak self] result, status in
                guard let self = self else { return }
                if status == .success{
                    self.getVodPlayApi(contentId: self.contentId.count>0 ? self.contentId : vodPlayBlockListListModel.contentId)
//                    if let vodPlayBlockListModel = self.dataArray[0] as? CNLiveVodPlayBlockListModel{
//                        if vodPlayBlockListModel.type == "5"{//简介
//                            if let model = vodPlayBlockListModel.list.first{
//                                model.liked = isLiked
//                                model.likesNum = favoriteNum
//                                self.dataArray.replaceObject(at: 0, with: vodPlayBlockListModel)
//                            }
//                            
//                        }
//                    }
//                    self.tableView.reloadRow(at: IndexPath(row: 0, section: 0), with: .none)
                }
            }
        }else{
            metaAppDelegate.pushLoginVC()
        }
    }
    
    func vodCollection(vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel,isCollectioned:Bool){
        if metaAppDelegate.isLogin{
            let type = isCollectioned ? "1" : "2"
            showLoading(message: "")
            CNLiveVodPlayViewModel.vodCollection(type: type, vodPlayBlockListListModel: vodPlayBlockListListModel) {[weak self] result, status in
                guard let self = self else { return }
                if status == .success{
                    self.getVodPlayApi(contentId: self.contentId.count>0 ? self.contentId : vodPlayBlockListListModel.contentId)
                }
            }
        }else{
            metaAppDelegate.pushLoginVC()
        }
    }
    func vodShare(vodPlayBlockListListModel:CNLiveVodPlayBlockListListModel){
        CNLiveShareManager.showShareViewWithParam(forShareTitle: vodPlayBlockListListModel.title, shareUrl: "https://wjjh5.cnlive.com/apkdownloadYuanma.php", shareDesc: vodPlayBlockListListModel.desc, shareImage: vodPlayBlockListListModel.img, screenFull: false, hiddenWjj: true, hiddenQQ: true, hiddenWB: true, hiddenLifeCircle: true, hiddenWechatCircle: false, hiddenWechat: false, hiddenSafari: true, formVC: currentViewController(), topImage: [], topTitles: [], platformType: .all) { title in
            
        } completerBlock: { resultType, platformType, typeString in
            if resultType == .succ{
                print("succ")
            }
        }
    }
    
    // MARK: - ButtonAction
    
    @objc func expandBtnAction() {
        //详情 收起
        self.bottomCommentShowContainView.removeAllSubviews()
        self.bottomCommentShowContainView.isHidden = true
    }
    @objc func bottomCommentViewTapAction() {
        if metaAppDelegate.isLogin{
            bottomCommentShowContainView.isHidden = false
            //评论
            CNLiveShortVideoCommentListView.showVideoCommentListView(pid: self.vodPlayModel?.contentId ?? "", contentSid: UserInfoManager.shared.userInfo.uid,containView:self.bottomCommentShowContainView, result: { commentModel in
                print("\(commentModel)")
            }, close: {[weak self] in
                guard let self = self else { return }
                self.bottomCommentShowContainView.isHidden = true
            })
        }else{
            metaAppDelegate.pushLoginVC()
        }
    }

    @objc func ClickBackBtn() {
        
        let viewControllers = self.navigationController?.viewControllers
        if viewControllers?.count ?? 0 > 1 {
            if viewControllers?.last == self {
                self.navigationController!.popViewController(animated: true)
            }
        }
        self.destroyPlayer()
        print("vod deinit back")
        NotificationCenter.default.removeObserver(self)
    }
    
    // MARK: - 获取默认商品block
    func getGoodBlockContents(){
        showLoading(message: "")
        CNLiveHomePageViewModel.getBlockContents(blockId: "12385", page: 1) {[weak self] result, status in
            hiddenLoading()
            guard let self = self else { return }
            if status == .success{
                let albumBaseModel = result as! CNLiveAlbumBaseModel
                var isHaveGoodjson = false//是否有默认商品
                for (_,mdl) in self.dataArray.enumerated(){
                    if let models = mdl as? [CNLiveAlbumModel]{
                        isHaveGoodjson = true
                    }
                }
                if !isHaveGoodjson{
                    self.dataArray.add(albumBaseModel.list)
                }
                self.tableView.reloadData()

            }else if (status == .noNetwork) {
//                    self.network_type = .noNetwork
//                    self.tableView.reloadEmptyDataSet()
            } else {
//                    self.network_type = .failed
//                    self.tableView.reloadEmptyDataSet()
            }
        }


    }

    // MARK: - 点播play接口
    /*
    func requestGetVodPlayApi(contentId:String){
        CNLiveHomePageViewModel.requestGetVodPlayApi(contentId: contentId, sid: UserInfoManager.shared.userInfo.uid, resultBlock: { result, status in
            if status == .success{
                if let vodPlayMpdel = result as? CNLiveVodPlayModel{
                    if let albumMdl = vodPlayMpdel.album{
                        //专辑
                        self.requestGetVodPlay1Api(contentId: vodPlayMpdel.contentId)
                        //记录当前播放集数的ContentId
                        self.contentId = vodPlayMpdel.contentId
                        self.requestGetAlbumMsgApi(contentId: vodPlayMpdel.contentId)
                    }else{
                        //单集
                        
                    }
                }
            }
        })
    }
    //专辑的单集内容
    func requestGetVodPlay1Api(contentId:String){
        CNLiveHomePageViewModel.requestGetVodPlayApi(contentId: contentId, sid: UserInfoManager.shared.userInfo.uid, resultBlock: { result, status in
            if status == .success{
                if let vodPlayMpdel = result as? CNLiveVodPlayModel{
                    if let albumMdl = vodPlayMpdel.album{
                        //专辑

                    }else{
                        //单集
                        
                    }
                }
            }
        })
    }
     */
    // MARK: - 专辑内容详情
//    func requestGetAlbumMsgApi(contentId:String){
//        CNLiveHomePageViewModel.requstWithVodAlbumMsgVideo(aid: contentId, resultBlock: { result, status in
//            if status == .success{
//                if let vodPlayMpdel = result as? CNLiveVodPlayModel{
//                    //专辑详情
//                }
//            }
//        })
//    }
    
    deinit {
        print("vod deinit")
        NotificationCenter.default.removeObserver(self)
    }
}