我正在尝试重现Flow文档中有关指定子prop的元素类型的步骤.这个例子是关于官方文档的.
我目前正在反应原生环境中测试它,使用:
我正在测试的代码是:
// @flow
import * as React from 'react'
import { StyleSheet, View, Text } from 'react-native'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
})
const Item = () => <Text>Item</Text>
type Props = {
children: React.ChildrenArray<React.Element<typeof Item>>,
}
const Container = (props: Props) => <View>{props.children}</View>
export default () => (
<View style={styles.container}>
<Container>
<Item />
<View />
</Container>
</View>
)
Run Code Online (Sandbox Code Playgroud)
预期的行为:从流中获取错误,因为我在View组件内部使用了一个Container组件,但我没有收到任何错误. …
我正在开发一种在后台播放音乐的音乐播放器.
该应用程序与Spotify和Apple音乐集成,用户只能在其中一项服务中进行身份验证.
目前,我可以在应用程序和后台播放两种服务的音乐.我也能够设置MPNowPlayingInfoCenter并显示正确的信息,但播放/暂停,下一首曲目和之前的曲目仅在用户使用Spotify进行身份验证时才有效.
当用户与Apple Music服务同步并尝试使用任何关闭命令时,应用程序无法接收通知,而Apple Music应用程序似乎正在处理它,从而播放Apple Music播放列表中的下一首歌曲而不是我的应用播放列表.
当我AVPlayer与Apple Music SPTAudioStreamingController同步并与Spotify同步时,我正在使用它来播放音乐.
我还验证了matt在这个问题上提出的要求:xcode - 在iOS 8上不显示MPNowPlayingInfoCenter信息
以下是媒体中心设置的代码:
- (void)setMediaCenterinfoForPlayer:(id)player {
SPTAudioStreamingController *spotifyPlayer;
AVPlayer *localPlayer;
NSMutableDictionary *trackInfo = [[NSMutableDictionary alloc] initWithDictionary: @{ MPMediaItemPropertyTitle: self.currentTrack.name,
MPMediaItemPropertyArtist: ((SPTArtist *)self.currentTrack.artists[0]).name,
MPMediaItemPropertyAlbumTitle : self.currentTrack.album.name,
MPNowPlayingInfoPropertyPlaybackRate: @(1.0)
}];
if ([player isKindOfClass:[SPTAudioStreamingController class]]) {
spotifyPlayer = (SPTAudioStreamingController *)player;
[trackInfo setObject:[NSNumber numberWithFloat:spotifyPlayer.currentPlaybackPosition] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
[trackInfo setObject:[NSNumber numberWithFloat:spotifyPlayer.currentTrackDuration] forKey:MPMediaItemPropertyPlaybackDuration];
} else {
localPlayer = (AVPlayer *)player;
NSTimeInterval playbackTime = [self currentPlaybackTimeForPlayer:player];
[trackInfo setObject:@(playbackTime) forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
[trackInfo …Run Code Online (Sandbox Code Playgroud)