Skip to content

Commit

Permalink
Update Expo libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
tekrei committed Jun 1, 2024
1 parent 0c7721f commit b356ecf
Show file tree
Hide file tree
Showing 3 changed files with 634 additions and 591 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"@react-navigation/native": "^6.1",
"expo": "^51",
"expo-av": "~14.0.5",
"expo-constants": "~16.0.1",
"expo-constants": "~16.0.2",
"expo-device": "~6.0.2",
"expo-linking": "~6.3.1",
"expo-notifications": "~0.28.3",
"expo-notifications": "~0.28.5",
"expo-status-bar": "~1.12.1",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
48 changes: 25 additions & 23 deletions src/components/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import { Platform, Text, TouchableOpacity, View } from "react-native";
import { Audio, InterruptionModeAndroid, InterruptionModeIOS } from "expo-av";
import * as Device from "expo-device";
import * as Notifications from "expo-notifications";
import { styles, LoopType, randomInt, useAppContext, error, show } from "../helpers";
import {
styles,
LoopType,
randomInt,
useAppContext,
error,
show,
} from "../helpers";
import PlayerControls from "./controls";
import SeekBar from "./seekbar";

Expand Down Expand Up @@ -42,7 +49,7 @@ async function registerForPushNotificationsAsync() {
});
}
} catch (e) {
error(`Bir hata oluştu: ${e}`);
error(`registerForPushNotificationsAsync: ${e}`);
}
}

Expand All @@ -67,7 +74,7 @@ const Player = () => {
// reduce sound of other apps
interruptionModeIOS: InterruptionModeIOS.DuckOthers,
interruptionModeAndroid: InterruptionModeAndroid.DuckOthers,
})
});

return () => {
Notifications.removeNotificationSubscription(
Expand All @@ -81,17 +88,13 @@ const Player = () => {
}, [playlist?.current]);

useEffect(() => {
try {
player
.setIsLoopingAsync(loop === LoopType.RepeatSong)
.then()
.catch((e) => {
error(`${e}`);
});
player.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
} catch (e) {
error(`${e}`);
}
player
.setStatusAsync({ isLooping: loop === LoopType.RepeatSong })
.then()
.catch((e) => {
error(`setIsLoopingAsync ${e}`);
});
player.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
}, [loop]);

const onPlaybackStatusUpdate = (status) => {
Expand All @@ -118,12 +121,11 @@ const Player = () => {
current: songs[randomInt(songs.length)],
index: -1,
});
}
else {
} else {
playSong();
}
} catch (e) {
error(`${e}`);
error(`randomTrack ${e}`);
}
};

Expand All @@ -138,7 +140,7 @@ const Player = () => {
setPlaylist({ ...playlist, ...{ index, current } });
}
} catch (e) {
error(`${e}`);
error(`previousTrack ${e}`);
}
};

Expand All @@ -153,7 +155,7 @@ const Player = () => {
setPlaylist({ ...playlist, ...{ index, current } });
}
} catch (e) {
error(`${e}`);
error(`nextTrack ${e}`);
}
};

Expand All @@ -163,7 +165,7 @@ const Player = () => {
.then(
(result) => result.isLoaded && player.setPositionAsync(positionMillis)
)
.catch((e) => error(`${e}`));
.catch((e) => error(`onSeek ${e}`));
};

const onPlay = () => {
Expand All @@ -184,7 +186,7 @@ const Player = () => {
}
}
})
.catch((e) => error(`${e}`));
.catch((e) => error(`onPlay ${e}`));
};

const playSong = () => {
Expand All @@ -209,10 +211,10 @@ const Player = () => {
.then(() =>
player.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate)
)
.catch((e) => error(`${e}`));
.catch((e) => error(`loadAsync ${e}`));
}
})
.catch((e) => error(`${e}`));
.catch((e) => error(`unloadAsync ${e}`));
};

return (
Expand Down
Loading

0 comments on commit b356ecf

Please sign in to comment.