فهرست منبع

修复线限耳机断开后停止播放
增加首次打开首页 引导用户好评的对话框

onecold 8 ماه پیش
والد
کامیت
f7b004e5d6

+ 0 - 11
entry/src/main/ets/common/constants/CommonConstants.ets

@@ -51,17 +51,6 @@ export class CommonConstants {
 
   static readonly COVER_API2: string = 'https://api.lrc.cx/cover'
 
-  //网络测速
-  static readonly IS_YUN_CESU: string = "https://test.nju.edu.cn/";
-  static readonly IS_YUN_CESU2: string = "http://speedtest.im/";
-  //教程
-  static readonly JIAO_CHENG: string = "https://seepwd.com/jiaocheng.html";
-  static readonly NODE_SPEED: string = "http://speedtest.zju.edu.cn/1000M";
-
-  static readonly MAC_API: string = "https://mac-4hh6rxuveq-de.a.run.app/mac?mac=";// https://api.ss5.xyz/mac?mac=98:97:CC:69:82:69
-
-
-  static readonly DEMO_MAGNET: string = "https://getsamplefiles.com/download/mp4/sample-5.mp4";
 
 
   static readonly PLAY_STORE:string = 'playAppStore'

+ 34 - 0
entry/src/main/ets/common/util/Utility.ets

@@ -264,6 +264,40 @@ export class Utility {
     return `${sampleRateKHz} KHz`;
   }
 
+  static  showHaoPingDialog(uicontext: UIContext,context:common.UIAbilityContext,appName:string,bundleName:string) {
+    try {
+      uicontext.getPromptAction().showDialog({
+        title: `喜欢${appName}吗?`,
+        message:'如果这个应用对您有帮助,请给我们一个五星好评,谢谢!让我们一起为鸿蒙生态助力,您的支持是我们努力提升的动力!让我们一起共赴鸿蒙满天星光。',
+        buttons: [
+          {
+            text: '下次再说',
+            color: '#000000'
+          },
+          {
+            text: '给个好评',
+            color: '#000000'
+          },
+        ]
+      }, (err, data) => {
+        if (err) {
+          console.error('showDialog err: ' + err);
+          return;
+        }
+        // 根据点击的按钮索引处理不同逻辑
+        if (data.index === 1) {//查看路径
+          Utility.gotoMarket(context, bundleName)
+        }
+        console.info('showDialog success callback, click button: ' + data.index);
+      });
+    } catch (error) {
+      let message = (error as BusinessError).message;
+      let code = (error as BusinessError).code;
+      console.error(`showDialog args error code is ${code}, message is ${message}`);
+    };
+
+  }
+
   static isMerge(localList:Array<VideoItem>,packName:string):boolean{
     if(ArrayUtil.isEmpty(localList))
       return false

+ 0 - 1
entry/src/main/ets/pages/MainIndex.ets

@@ -1,6 +1,5 @@
 import ScreenUtil from '../common/util/ScreenUtil'
 
-import { StreamContent } from '../view/StreamContent'
 import { window } from '@kit.ArkUI'
 import { common } from '@kit.AbilityKit'
 import { AvSessionController } from '../controller/AvSessionController'

+ 7 - 0
entry/src/main/ets/pages/NewIndex.ets

@@ -348,6 +348,13 @@ struct NewIndex {
       LogUtil.info('heanup NewIndex', '收到歌单刷新事件,开始刷新歌单列表')
       this.loadPlaylistList()
     });
+
+    if(Utility.isOpenTime()&&!PreferencesUtil.getBooleanSync('isShowHaoPingDialog', false)){
+      setTimeout(()=>{
+        Utility.showHaoPingDialog(this.getUIContext(),this.context,this.appName,this.bundleName)
+        PreferencesUtil.putSync('isShowHaoPingDialog', true)
+      },20000)
+    }
   }
 
   /**

+ 2 - 1
entry/src/main/ets/pages/SettingPage.ets

@@ -1216,7 +1216,8 @@ export struct SettingPage {
                 .fontColor(Color.Gray)
                 .margin({ right: 18 })
                 .selected(this.twoFingerType - 1)
-                .value(CommonConstants.TWO_FINGER_TYPE[this.twoFingerType-1])
+                .value(this.twoFingerType>3? CommonConstants.TWO_FINGER_TYPE[2]:
+                  CommonConstants.TWO_FINGER_TYPE[this.twoFingerType-1])
                 .onSelect(async (_index: number, text?: string | undefined) => {
                   _index++;
                   this.twoFingerType = _index

+ 11 - 1
entry/src/main/ets/view/LocalMusic.ets

@@ -1298,7 +1298,7 @@ export struct LocalMusic {
 
     }
     this.mIjkMediaPlayer.on('audioInterrupt', event);
-    // 音频设备断连回调处理
+    // 音频设备断连回调处理比如蓝牙耳机断开
     let deviceChangeEvent: Callback<InterruptEvent> = (event) => {
       LogUtils.getInstance().LOGI(`Heanup deviceChange event: ${JSON.stringify(event)}`);
       if (event.reason === DeviceChangeReason.REASON_NEW_DEVICE_AVAILABLE) { // 音频设备连接
@@ -1318,6 +1318,16 @@ export struct LocalMusic {
 
     });
 
+    // 有线耳机断开和连接的监听。监听音频设备状态变化。
+    let audioManager = audio.getAudioManager();  // 需要先创建AudioManager实例。
+    let audioRoutingManager = audioManager.getRoutingManager();  // 再调用AudioManager的方法创建AudioRoutingManager实例。
+    audioRoutingManager.on('deviceChange', audio.DeviceFlag.INPUT_DEVICES_FLAG, (deviceChanged: audio.DeviceChangeAction) => {
+      console.info('device change type : ' + deviceChanged.type);  // 设备连接状态变化,0为连接,1为断开连接。
+      if(deviceChanged.type==1){
+        this.pause();
+      }
+    });
+
 
     this.makeWorker()
 

+ 0 - 387
entry/src/main/ets/view/StreamContent.ets

@@ -1,387 +0,0 @@
-import TitleBar from './TitleBar'
-import { router } from '@kit.ArkUI';
-import { CommonConstants } from '../common/constants/CommonConstants';
-import Logger from '../common/util/Logger';
-import { VideoItem } from '../viewmodel/VideoItem';
-// import { AdSlot, AdSlotBuilder,
-//   CSJAdCreator,
-//   CSJAdSdk, CSJNativeExpressAd, NativeExpressAdListener } from '@csj/openadsdk';
-import { PrintBiddingTokenUtils } from '../common/util/PrintBiddintTokenUtils';
-import { ArrayList } from '@kit.ArkTS';
-import { CSJUtil } from '../common/util/CSJUtil';
-import { Utility } from '../common/util/Utility';
-import { DialogHelper } from '@pura/harmony-dialog';
-import { AppUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
-import { common } from '@kit.AbilityKit';
-
-const context = getContext(this) as common.UIAbilityContext;
-@Preview
-@Component
-export  struct  StreamContent{
-  @State bundleName:string =''
-  @State textStr:string = ''
-  @State  videoInList: Array<VideoItem> = []
-  @Consume isShowDrawer:boolean;
-  @Consume offsetX: number ;
-  @State titleBarModel: TitleBar.Model = new TitleBar.Model()
-    .setTitleTextStyle(FontStyle.Normal)
-    .setTitleBarStyle(TitleBar.BarStyle.TRANSPARENT)
-    .setLeftIcon($r('app.media.menu'))
-    .setLeftIconWidth(25)
-    .setLeftIconHeight(25)
-    .setTitleName("流媒体播放")
-    .setTitleFontColor(Color.White)
-    .setTitleBarBackground($r('app.color.title_bar_bg'))
-    .setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
-
-    .setOnLeftClickListener(()=>{
-
-        animateTo({ duration: 800 }, () => {
-          // 动画闭包内控制Image组件的出现和消失
-          this.isShowDrawer = true
-          this.offsetX = 0
-        })
-
-
-
-    })
-
-
-  // 组件生命周期
-  async aboutToAppear() {
-    //穿山甲
-    // this.loadBannerAd( CSJUtil.getBannerID())
-    this.bundleName = await  AppUtil.getBundleName()
-  }
-
-
-  // 组件消失生命周期
-  aboutToDisappear() {
-    console.info('LifeCycleComponent aboutToDisappear');
-  }
-
-  showHaopingDialog(){
-
-
-    DialogHelper.showCustomContentDialog({
-      dialogId:'haoping',
-      title: "该功能免费",
-      autoCancel: false, //点击遮障层时,不关闭弹窗
-      backCancel: true, //点击返回键,不关闭弹窗
-      contentBuilder: () => {
-        this.customHaoPingBuilder("如果您觉得好用可以给个好评吗?谢谢!\n给个好评吧,非常感谢您的支持!")
-      },
-      buttons: [],
-
-
-    })
-
-
-  }
-
-
-  doPlay(){
-    if(StrUtil.isEmpty(this.textStr)){
-      return
-    }
-    if(this.textStr.indexOf("douyin.com") !== -1)
-    {
-      ToastUtil.showToast('不支持抖音的复制的链接。')
-      return
-    }
-    if(Utility.isHaoFreeTime()){
-      let isHao:boolean = PreferencesUtil.getBooleanSync('is_haoping');
-      if(!isHao){
-        this.showHaopingDialog()
-        return
-      }
-    }
-
-    let item  = new VideoItem('',this.textStr,this.textStr,0,0,'')
-    this.videoInList.push(item)
-
-    router.pushUrl({ url: "pages/IjkVideoPlayerPage", params: {
-      name: item.filePath,
-      index: 0,
-      playType:2,//0:连续播放  1:单片重复播放 2:正常播放
-      videoUrl: item.filePath,
-      globalVideoList: this.videoInList
-    } }).catch((err: Error) => {
-      Logger.error('[IndexTabLocalList] router error: ' + JSON.stringify(err))
-    });
-
-
-    // router.pushUrl({
-    //   url: CommonConstants.PAGE,
-    //   params: {
-    //     src: this.textStr,
-    //     iSrc: this.textStr,
-    //     index: 0,
-    //     type: CommonConstants.TYPE_INTERNET,
-    //     globalVideoList:this.videoInList
-    //   }
-    // }).catch((err: Error) => {
-    //   Logger.error('[IndexTabLocalList] router error: ' + JSON.stringify(err))
-    // });
-
-  }
-
-  //好评的自定义内容
-  @Builder
-  customHaoPingBuilder(content: string) {
-    Column() {
-      Text(content)
-        .fontColor(Color.Gray)
-        .fontSize(16)
-        .alignSelf(ItemAlign.Start)
-        .margin({bottom:15})
-        .fontSize(16)
-
-      Row(){
-        Button('取消')
-          .fontColor(Color.White)
-          .backgroundColor($r('app.color.title_bar_bg'))
-          //.linearGradient( { direction: GradientDirection.Right, colors:[['#ff37a0fc',0.0],['#67e667',0.5],['#f5856e',1.0]]})
-          .height(50)
-          .layoutWeight(1)
-          .stateEffect(true)
-          .margin({right:6})
-          .onClick(()=>{
-            DialogHelper.closeDialog('haoping'); //关闭弹框
-          })
-        Button('好评')
-          .fontColor(Color.White)
-          //.linearGradient( { direction: GradientDirection.Right, colors:[['#ff37a0fc',0.0],['#67e667',0.5],['#f5856e',1.0]]})
-          .layoutWeight(1)
-          .height(50)
-          .backgroundColor($r('app.color.title_bar_bg'))
-          .stateEffect(true)
-          .margin({left:6})
-          .onClick(()=>{
-            DialogHelper.closeDialog('haoping'); //关闭弹框
-            Utility.gotoMarket(context,this.bundleName)
-            PreferencesUtil.putSync("is_haoping", true);
-          })
-      }
-
-    }
-    .width("100%")
-    .padding(10)
-  }
-
-
-  build() {
-
-    Scroll(){
-      Column() {
-        TitleBar({ model: $titleBarModel })
-        Column(){
-
-
-          Text('请在下方输入流媒体链接:')
-            .fontSize(12)
-            .fontWeight(300)
-            .visibility(Visibility.None)
-            .fontColor(Color.Grey)
-            .margin({ top: 20,bottom:20 })
-
-
-          TextArea({placeholder:'请在下方输入流媒体链接:如http://',text:CommonConstants.DEMO_MAGNET})
-            .type(TextAreaType.NORMAL)
-            .height(100)
-            .maxLines(3)
-            .margin({top:20,right:20,left:20})
-            .onChange((val:string)=>{
-              this.textStr = val
-            })
-
-          //穿山甲
-          // if (this.isShowAd) {
-          //   NodeContainer(this.bannerAd.getAdComponent())
-          //     .width(this.mAdSlot.getAcceptWidth())
-          //     .height(this.mAdSlot.getAcceptHeight())
-          //     .alignSelf(ItemAlign.Center)
-          //     .align(Alignment.Center);
-          // }
-
-          Column() {
-            Button('播放', { type: ButtonType.Capsule, stateEffect: true })
-
-              .width('80%')
-              .height(55)
-              .margin({ top: 30, bottom: 20 })
-              // .linearGradient({
-              //   direction: GradientDirection.Right,
-              //   colors: [['#ff37a0fc', 0.0], ['#f5856e', 0.5], ['#67e667', 1.0]]
-              // })
-              .backgroundColor($r('app.color.title_bar_bg'))
-
-              .onClick(() => {
-                this.doPlay()
-
-              })
-
-          }
-        }
-        .width('100%')
-        .height('100%')
-        .backgroundColor(Color.White)
-
-
-
-
-
-      }
-    }
-
-
-  }
-
-  //
-  // /**
-  //  * 穿山甲banner广告
-  //  */
-  // private declare bannerAd: CSJNativeExpressAd;
-  // @State private status: string = "未加载"
-  // @State private isShowAd: boolean = false
-  // private declare mAdSlot: AdSlot;
-  // private mBiddingAdm = '' //服务端bidding才需要设置
-  // private expressLoadAdListener: NativeExpressAdListener = {
-  //   /**
-  //    * 加载失败的回调
-  //    *
-  //    * @param code
-  //    * @param message
-  //    */
-  //   onError: (code: number, message: string) => {
-  //     console.error("加载广告失败,code=" + code + ",message=" + message);
-  //     this.status = "加载广告失败,code=" + code + ",message=" + message;
-  //   },
-  //
-  //   /**
-  //    * 广告加载成功的回调,接入方可以在这个回调中进行渲染
-  //    *
-  //    * @param ads 返回的广告列表
-  //    */
-  //
-  //   onNativeExpressAdLoad: (ads: ArrayList<CSJNativeExpressAd>) => {
-  //     console.log("BannerExpressAdPage==onNativeExpressAdLoad......success");
-  //     if (ads && ads.length > 0) {
-  //       ads.forEach((ad: CSJNativeExpressAd, idx: number) => {
-  //         ad.setExpressInteractionListener({
-  //           /**
-  //            *广告的点击回调
-  //            * @param type 广告的交互类型
-  //            */
-  //           onAdClicked: (type: number) => {
-  //             console.log("BannerExpressAdPage==onAdClicked......");
-  //           },
-  //
-  //           /**
-  //            * 广告的展示回调 每个广告仅回调一次
-  //            * @param type 广告的交互类型
-  //            */
-  //           onAdShow: (type: number) => {
-  //             console.log("BannerExpressAdPage==onAdShow......");
-  //           },
-  //
-  //           /**
-  //            * 模板渲染失败
-  //            */
-  //           onRenderFail: (code: number, msg: string) => {
-  //             console.log("BannerExpressAdPage==onRenderFail...code=" + code + ",msg=" + msg);
-  //           },
-  //
-  //           /**
-  //            * 模板渲染成功
-  //            * @param width  返回view的宽 单位 vp
-  //            * @param height 返回view的高 单位 vp
-  //            */
-  //           onRenderSuccess: (width: number, height: number) => {
-  //             console.log("BannerExpressAdPage==onRenderSuccess......width=" + width + ",height=" + height);
-  //             this.bannerAd = ad;
-  //             this.status = "广告加载完成待展示";
-  //
-  //             this.showBannerAd()
-  //           }
-  //         })
-  //         //渲染广告
-  //         ad.setSlideIntervalTime(30 * 1000);//设置轮播时间长
-  //         this.setDislikeCallback(ad); //设置dislike
-  //         ad.render(this.getUIContext())
-  //         this.status = "广告加载中...";
-  //       });
-  //     }
-  //   }
-  // }
-  //
-  // private setDislikeCallback(ad: CSJNativeExpressAd) {
-  //   ad.setDislikeCallback({
-  //     /**
-  //      * dislike show
-  //      */
-  //     onShow: () => {
-  //       console.log("BannerExpressAdPage==dislike......show");
-  //     },
-  //
-  //     /**
-  //      * @param position 选择的位置
-  //      * @param value 选择的内容
-  //      * @param enforceRemove 是否强制关闭广告
-  //      */
-  //     onSelected: (position: number, value: string, enforceRemove: boolean) => {
-  //       this.isShowAd = false;
-  //       console.log("BannerExpressAdPage==dislike......onSelected:position=" + position + ",value:" + value + ",enforce=" + enforceRemove);
-  //     },
-  //
-  //     /**
-  //      * 点击取消
-  //      */
-  //     onCancel: () => {
-  //       console.log("BannerExpressAdPage==dislike......onCancel");
-  //     }
-  //
-  //   })
-  // }
-  //
-  // /**
-  //  * 加载Banner广告
-  //  */
-  // loadBannerAd(rit: string) {
-  //   if(!Utility.isNoble()){
-  //     return
-  //   }
-  //   if(!Utility.isPassInstallTime(2)){
-  //     return
-  //   }
-  //   // if(!Utility.isFreeTime())
-  //   //   return
-  //   this.isShowAd = false;
-  //   let adCreator:CSJAdCreator = CSJAdSdk.getAdCreator()
-  //   this.mAdSlot = new AdSlotBuilder()
-  //     .setCodeId(rit)
-  //     .setAcceptSize(CSJUtil.BANNER_WIGTH, CSJUtil.BANNER_HEIGHT)
-  //     .setAdCount(1)
-  //     .setBidAdm(this.mBiddingAdm)
-  //     .build()
-  //   PrintBiddingTokenUtils.printBiddingToken(this.mAdSlot, adCreator);
-  //   adCreator.loadBannerAd(this.mAdSlot, this.expressLoadAdListener)
-  //   this.status = "广告加载中..."
-  // }
-  //
-  // /**
-  //  * 展示Banner广告
-  //  */
-  // showBannerAd() {
-  //   if (!this.bannerAd) {
-  //     return
-  //   }
-  //   this.isShowAd = true
-  //   this.status = "已展示"
-  // }
-  /**
-   * 穿山甲广告代码结束
-   */
-
-
-}