refactor(02-01): add [BTP] prefix to console logs for easier filtering
This commit is contained in:
parent
fc2b263550
commit
3fb2352409
|
|
@ -47,7 +47,7 @@ const JKSessionBackingTrackPlayer = ({
|
|||
const fetchDuration = async () => {
|
||||
try {
|
||||
const durationInMs = await jamClient.SessionGetTracksPlayDurationMs();
|
||||
console.log('JKSessionBackingTrackPlayer: Duration from jamClient:', durationInMs, 'Type:', typeof durationInMs);
|
||||
console.log('[BTP] Duration from jamClient:', durationInMs, 'Type:', typeof durationInMs);
|
||||
|
||||
// Convert string to number (jamClient returns string values)
|
||||
const validDuration = parseInt(durationInMs, 10) || 0;
|
||||
|
|
@ -79,7 +79,7 @@ const JKSessionBackingTrackPlayer = ({
|
|||
const durationInMs = await jamClient.SessionGetTracksPlayDurationMs();
|
||||
const trackIsPlaying = await jamClient.isSessionTrackPlaying();
|
||||
|
||||
console.log('JKSessionBackingTrackPlayer polling:', { positionMs, durationInMs, trackIsPlaying });
|
||||
console.log('[BTP] Polling:', { positionMs, durationInMs, trackIsPlaying });
|
||||
|
||||
// Convert strings to numbers (jamClient returns string values)
|
||||
const validPosition = parseInt(positionMs, 10) || 0;
|
||||
|
|
@ -87,7 +87,7 @@ const JKSessionBackingTrackPlayer = ({
|
|||
|
||||
// Check if track reached the end
|
||||
if (validPosition >= validDuration && validDuration > 0) {
|
||||
console.log('JKSessionBackingTrackPlayer: Track reached end, stopping playback');
|
||||
console.log('[BTP] Track reached end, stopping playback');
|
||||
setIsPlaying(false);
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ const JKSessionBackingTrackPlayer = ({
|
|||
|
||||
// Sync playing state if changed
|
||||
if (trackIsPlaying !== isPlaying) {
|
||||
console.log('JKSessionBackingTrackPlayer: Playing state changed from', isPlaying, 'to', trackIsPlaying);
|
||||
console.log('[BTP] Playing state changed from', isPlaying, 'to', trackIsPlaying);
|
||||
setIsPlaying(trackIsPlaying);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -117,7 +117,7 @@ const JKSessionBackingTrackPlayer = ({
|
|||
|
||||
const handlePlay = async () => {
|
||||
try {
|
||||
console.log('JKSessionBackingTrackPlayer handlePlay:', {
|
||||
console.log('[BTP] handlePlay:', {
|
||||
isPlaying,
|
||||
currentPositionMs,
|
||||
durationMs
|
||||
|
|
@ -127,24 +127,31 @@ const JKSessionBackingTrackPlayer = ({
|
|||
// Pause
|
||||
await jamClient.SessionPausePlay();
|
||||
setIsPlaying(false);
|
||||
console.log('JKSessionBackingTrackPlayer: Paused');
|
||||
console.log('[BTP] Paused');
|
||||
} else {
|
||||
// Check if we're at or very near the end (within 100ms)
|
||||
if (currentPositionMs >= durationMs - 100 && durationMs > 0) {
|
||||
console.log('JKSessionBackingTrackPlayer: At end of track, resetting to start before play');
|
||||
// Check if we're at the very end (within 50ms to avoid false positives from slider dragging)
|
||||
if (currentPositionMs >= durationMs - 50 && durationMs > 0) {
|
||||
console.log('[BTP] At end of track, resetting to start before play', {
|
||||
currentPositionMs,
|
||||
durationMs,
|
||||
diff: durationMs - currentPositionMs
|
||||
});
|
||||
// Stop first to reset state
|
||||
await jamClient.SessionStopPlay();
|
||||
console.log('[BTP] Stop completed');
|
||||
// Seek to start
|
||||
await jamClient.SessionTrackSeekMs(0);
|
||||
console.log('[BTP] Seek to 0 completed');
|
||||
// Update UI state
|
||||
setCurrentPositionMs(0);
|
||||
setCurrentTime('0:00');
|
||||
}
|
||||
|
||||
// Play (1 = normal playback mode)
|
||||
console.log('[BTP] About to call SessionStartPlay');
|
||||
await jamClient.SessionStartPlay(1);
|
||||
setIsPlaying(true);
|
||||
console.log('JKSessionBackingTrackPlayer: Playing');
|
||||
console.log('[BTP] SessionStartPlay completed, isPlaying set to true');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error toggling playback:', error);
|
||||
|
|
@ -202,7 +209,7 @@ const JKSessionBackingTrackPlayer = ({
|
|||
const seekPositionMs = parseInt(e.target.value);
|
||||
|
||||
try {
|
||||
console.log('JKSessionBackingTrackPlayer handleSeek:', {
|
||||
console.log('[BTP] handleSeek:', {
|
||||
seekPositionMs,
|
||||
durationMs,
|
||||
isPlaying,
|
||||
|
|
@ -216,7 +223,7 @@ const JKSessionBackingTrackPlayer = ({
|
|||
// Seek the native client to the new position
|
||||
await jamClient.SessionTrackSeekMs(seekPositionMs);
|
||||
|
||||
console.log('JKSessionBackingTrackPlayer: Seek completed');
|
||||
console.log('[BTP] Seek completed');
|
||||
} catch (error) {
|
||||
console.error('Error seeking:', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue