mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-02-02 00:18:08 +00:00
fix: convert native.js to native.ts and fix imports for EAS builds
- Convert utils/profiles/native.js to TypeScript - Add barrel export index.ts for profiles - Update all imports to use explicit file paths instead of barrel export - Fix .gitignore to only ignore root-level profiles/ directory
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -61,7 +61,7 @@ expo-env.d.ts
|
||||
pc-api-7079014811501811218-719-3b9f15aeccf8.json
|
||||
credentials.json
|
||||
streamyfin-4fec1-firebase-adminsdk.json
|
||||
profiles/
|
||||
/profiles/
|
||||
certs/
|
||||
|
||||
# Version and Backup Files
|
||||
|
||||
@@ -57,8 +57,8 @@ import {
|
||||
getMpvSubtitleId,
|
||||
} from "@/utils/jellyfin/subtitleUtils";
|
||||
import { writeToLog } from "@/utils/log";
|
||||
import { generateDeviceProfile } from "@/utils/profiles/native";
|
||||
import { msToTicks, ticksToSeconds } from "@/utils/time";
|
||||
import { generateDeviceProfile } from "../../../utils/profiles/native";
|
||||
|
||||
export default function page() {
|
||||
const videoRef = useRef<MpvPlayerViewRef>(null);
|
||||
|
||||
@@ -35,9 +35,9 @@ import { useSettings } from "@/utils/atoms/settings";
|
||||
import { getParentBackdropImageUrl } from "@/utils/jellyfin/image/getParentBackdropImageUrl";
|
||||
import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl";
|
||||
import { getStreamUrl } from "@/utils/jellyfin/media/getStreamUrl";
|
||||
import { chromecast } from "@/utils/profiles/chromecast";
|
||||
import { chromecasth265 } from "@/utils/profiles/chromecasth265";
|
||||
import { runtimeTicksToMinutes } from "@/utils/time";
|
||||
import { chromecast } from "../utils/profiles/chromecast";
|
||||
import { chromecasth265 } from "../utils/profiles/chromecasth265";
|
||||
import { Button } from "./Button";
|
||||
import { Text } from "./common/Text";
|
||||
import type { SelectedOptions } from "./ItemContent";
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Platform } from "react-native";
|
||||
import type { Bitrate } from "@/components/BitrateSelector";
|
||||
import { settingsAtom } from "@/utils/atoms/settings";
|
||||
import { getStreamUrl } from "@/utils/jellyfin/media/getStreamUrl";
|
||||
import { generateDeviceProfile } from "@/utils/profiles/native";
|
||||
import { generateDeviceProfile } from "../utils/profiles/native";
|
||||
import { apiAtom, userAtom } from "./JellyfinProvider";
|
||||
|
||||
export type PlaybackType = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { MediaSourceInfo } from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api";
|
||||
import trackPlayerProfile from "@/utils/profiles/trackplayer";
|
||||
import trackPlayerProfile from "../../profiles/trackplayer";
|
||||
|
||||
export interface AudioStreamResult {
|
||||
url: string;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Bitrate } from "@/components/BitrateSelector";
|
||||
import {
|
||||
type AudioTranscodeModeType,
|
||||
generateDeviceProfile,
|
||||
} from "@/utils/profiles/native";
|
||||
} from "../../profiles/native";
|
||||
import { getDownloadStreamUrl, getStreamUrl } from "./getStreamUrl";
|
||||
|
||||
export const getDownloadUrl = async ({
|
||||
|
||||
@@ -5,8 +5,8 @@ import type {
|
||||
} from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client/models/base-item-kind";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api";
|
||||
import { generateDownloadProfile } from "@/utils/profiles/download";
|
||||
import type { AudioTranscodeModeType } from "@/utils/profiles/native";
|
||||
import { generateDownloadProfile } from "../../profiles/download";
|
||||
import type { AudioTranscodeModeType } from "../../profiles/native";
|
||||
|
||||
interface StreamResult {
|
||||
url: string;
|
||||
|
||||
6
utils/profiles/index.ts
Normal file
6
utils/profiles/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export { chromecast } from "./chromecast";
|
||||
export { chromecasth265 } from "./chromecasth265";
|
||||
export { generateDownloadProfile } from "./download";
|
||||
export * from "./native";
|
||||
export { default } from "./native";
|
||||
export { default as trackPlayerProfile } from "./trackplayer";
|
||||
23
utils/profiles/native.d.ts
vendored
23
utils/profiles/native.d.ts
vendored
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
export type PlatformType = "ios" | "android";
|
||||
export type PlayerType = "mpv";
|
||||
export type AudioTranscodeModeType = "auto" | "stereo" | "5.1" | "passthrough";
|
||||
|
||||
export interface ProfileOptions {
|
||||
/** Target platform */
|
||||
platform?: PlatformType;
|
||||
/** Video player being used */
|
||||
player?: PlayerType;
|
||||
/** Audio transcoding mode */
|
||||
audioMode?: AudioTranscodeModeType;
|
||||
}
|
||||
|
||||
export function generateDeviceProfile(options?: ProfileOptions): any;
|
||||
|
||||
declare const _default: any;
|
||||
export default _default;
|
||||
@@ -7,22 +7,24 @@ import { Platform } from "react-native";
|
||||
import MediaTypes from "../../constants/MediaTypes";
|
||||
import { getSubtitleProfiles } from "./subtitles";
|
||||
|
||||
/**
|
||||
* @typedef {"ios" | "android"} PlatformType
|
||||
* @typedef {"mpv"} PlayerType
|
||||
* @typedef {"auto" | "stereo" | "5.1" | "passthrough"} AudioTranscodeModeType
|
||||
*
|
||||
* @typedef {Object} ProfileOptions
|
||||
* @property {PlatformType} [platform] - Target platform
|
||||
* @property {PlayerType} [player] - Video player being used (MPV only)
|
||||
* @property {AudioTranscodeModeType} [audioMode] - Audio transcoding mode
|
||||
*/
|
||||
export type PlatformType = "ios" | "android";
|
||||
export type PlayerType = "mpv";
|
||||
export type AudioTranscodeModeType = "auto" | "stereo" | "5.1" | "passthrough";
|
||||
|
||||
export interface ProfileOptions {
|
||||
/** Target platform */
|
||||
platform?: PlatformType;
|
||||
/** Video player being used */
|
||||
player?: PlayerType;
|
||||
/** Audio transcoding mode */
|
||||
audioMode?: AudioTranscodeModeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Audio direct play profiles for standalone audio items in MPV player.
|
||||
* These define which audio file formats can be played directly without transcoding.
|
||||
*/
|
||||
const getAudioDirectPlayProfile = (platform) => {
|
||||
const getAudioDirectPlayProfile = (platform: PlatformType) => {
|
||||
if (platform === "ios") {
|
||||
// iOS audio formats supported by MPV
|
||||
return {
|
||||
@@ -44,7 +46,7 @@ const getAudioDirectPlayProfile = (platform) => {
|
||||
* Audio codec profiles for standalone audio items in MPV player.
|
||||
* These define codec constraints for audio file playback.
|
||||
*/
|
||||
const getAudioCodecProfile = (platform) => {
|
||||
const getAudioCodecProfile = (platform: PlatformType) => {
|
||||
if (platform === "ios") {
|
||||
// iOS audio codec constraints for MPV
|
||||
return {
|
||||
@@ -66,12 +68,11 @@ const getAudioCodecProfile = (platform) => {
|
||||
* MPV (via FFmpeg) can decode all audio codecs including TrueHD and DTS-HD MA.
|
||||
* The audioMode setting only controls the maximum channel count - MPV will
|
||||
* decode and downmix as needed.
|
||||
*
|
||||
* @param {PlatformType} platform
|
||||
* @param {AudioTranscodeModeType} audioMode
|
||||
* @returns {{ directPlayCodec: string, maxAudioChannels: string }}
|
||||
*/
|
||||
const getVideoAudioCodecs = (platform, audioMode) => {
|
||||
const getVideoAudioCodecs = (
|
||||
platform: PlatformType,
|
||||
audioMode: AudioTranscodeModeType,
|
||||
): { directPlayCodec: string; maxAudioChannels: string } => {
|
||||
// Base codecs
|
||||
const baseCodecs = "aac,mp3,flac,opus,vorbis";
|
||||
|
||||
@@ -120,12 +121,9 @@ const getVideoAudioCodecs = (platform, audioMode) => {
|
||||
|
||||
/**
|
||||
* Generates a device profile for Jellyfin playback.
|
||||
*
|
||||
* @param {ProfileOptions} [options] - Profile configuration options
|
||||
* @returns {Object} Jellyfin device profile
|
||||
*/
|
||||
export const generateDeviceProfile = (options = {}) => {
|
||||
const platform = options.platform || Platform.OS;
|
||||
export const generateDeviceProfile = (options: ProfileOptions = {}) => {
|
||||
const platform = (options.platform || Platform.OS) as PlatformType;
|
||||
const audioMode = options.audioMode || "auto";
|
||||
|
||||
const { directPlayCodec, maxAudioChannels } = getVideoAudioCodecs(
|
||||
Reference in New Issue
Block a user