Pārlūkot izejas kodu

撤销刚刚提交的代码 会导致其他正常的音乐也拖动不了

onecold 4 mēneši atpakaļ
vecāks
revīzija
965c42d081

+ 1 - 11
entry/src/main/ets/common/util/PlaybackSeekGuard.ets

@@ -1,5 +1,3 @@
-import { CommonConstants } from '../constants/CommonConstants';
-
 export interface SeekGuardDecision {
   allow: boolean;
   reason: string;
@@ -14,7 +12,7 @@ export function isBaiduStreamingPlaybackUrl(url?: string): boolean {
   return lowerUrl.includes('pan.baidu.com/rest/2.0/xpan/file') && lowerUrl.includes('method=streaming');
 }
 
-export function resolveSeekGuardDecision(url: string, targetMs: number, songType?: number): SeekGuardDecision {
+export function resolveSeekGuardDecision(url: string, targetMs: number): SeekGuardDecision {
   if (targetMs <= 0) {
     return {
       allow: true,
@@ -31,14 +29,6 @@ export function resolveSeekGuardDecision(url: string, targetMs: number, songType
     };
   }
 
-  if (songType === CommonConstants.TYPE_BAIDU) {
-    return {
-      allow: false,
-      reason: 'baidu-song-positive-seek',
-      toastMessage: '当前百度流播音源暂不支持拖动定位,已阻止本次跳转以避免闪退'
-    };
-  }
-
   return {
     allow: true,
     reason: 'allowed',

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

@@ -17407,7 +17407,7 @@ export struct LocalMusic {
   }
 
   private handleBlockedSeek(seekPos: number, source: string): boolean {
-    const decision = resolveSeekGuardDecision(this.videoUrl, seekPos, this.currentSong?.type);
+    const decision = resolveSeekGuardDecision(this.videoUrl, seekPos);
     if (decision.allow) {
       return false;
     }

+ 0 - 12
entry/src/ohosTest/ets/test/PlaybackSeekGuard.test.ets

@@ -1,6 +1,5 @@
 import { describe, it, expect } from '@ohos/hypium'
 import { resolveSeekGuardDecision } from '../../../main/ets/common/util/PlaybackSeekGuard'
-import { CommonConstants } from '../../../main/ets/common/constants/CommonConstants'
 
 export default function playbackSeekGuardTest() {
   describe('PlaybackSeekGuardTest', () => {
@@ -28,16 +27,5 @@ export default function playbackSeekGuardTest() {
 
       expect(decision.allow).assertTrue()
     })
-
-    it('blocksPositiveSeekForBaiduSongTypeEvenIfUrlDoesNotContainStreamingFlag', 0, () => {
-      const decision = resolveSeekGuardDecision(
-        'https://example-cdn.baidu.test/audio/segment-list.m3u8',
-        93000,
-        CommonConstants.TYPE_BAIDU
-      )
-
-      expect(decision.allow).assertFalse()
-      expect(decision.reason).assertEqual('baidu-song-positive-seek')
-    })
   })
 }

+ 4 - 13
ijkplayer/src/main/cpp/ijkplayer/ff_ffplay.c

@@ -3134,20 +3134,12 @@ static int is_network_time_seekable_input(AVFormatContext *ic)
            strstr(format_name, "applehttp") != NULL;
 }
 
-static int has_renderable_video_stream(VideoState *is)
-{
-    if (!is || is->video_stream < 0 || !is->video_st) {
-        return 0;
-    }
-    return !(is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC);
-}
-
 static int allow_network_time_seek_for_stream(AVFormatContext *ic, VideoState *is)
 {
     if (!is_network_time_seekable_input(ic) || !is) {
         return 0;
     }
-    return has_renderable_video_stream(is);
+    return is->video_stream >= 0;
 }
 
 
@@ -3569,8 +3561,7 @@ static int read_thread(void *arg)
                                      (strcmp(ic->iformat->name, "asf") == 0 ||
                                       strcmp(ic->iformat->name, "asf_o") == 0 ||
                                       strstr(ic->iformat->name, "asf") != NULL));
-                int is_audio_only_stream = !has_renderable_video_stream(is);
-                int use_safe_byte_seek = is_asf_format || is_audio_only_stream;
+                int use_safe_byte_seek = is_asf_format;
                 int64_t local_seek_target = seek_target;
                 int64_t local_seek_min = seek_min;
                 int64_t local_seek_max = seek_max;
@@ -3592,8 +3583,8 @@ static int read_thread(void *arg)
                 effective_seek_target = local_seek_target;
 
                 if (use_safe_byte_seek) {
-                    // Avoid avformat_seek_file for fragile local ASF/audio-only streams.
-                    const char *safe_seek_name = is_asf_format ? "ASF" : "audio-only";
+                    // Avoid avformat_seek_file for fragile local ASF streams.
+                    const char *safe_seek_name = "ASF";
                     if (!ic->pb || !(ic->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
                         av_log(ffp, AV_LOG_WARNING, "heanup: %s stream is not byte-seekable, reject seek\n", safe_seek_name);
                         ret = -1;