相关疑难解决方法(0)

使用HTML5在iPad上自动播放音频文件

我正试图在iPad上的Safari中自动播放音频文件.如果我在Mac上使用Safari进入页面,那很好.在iPad上,自动播放不起作用.

iphone audio html5 ipad

87
推荐指数
8
解决办法
17万
查看次数

如何自动播放youtube嵌入式视频反应原生?

我试图在我的本机应用程序中自动播放youtube嵌入式视频.

这是我的代码,

render() {
    const { data } = this.props;
    const { loading } = this.state;
    return (
        <View>
            <CloseButton onTrigger={this.closeModal.bind(this)} />
            <PlayIcon onTrigger={this.playVideo} />
            <Image source={{uri:data.src}} resize='contain' style={{height:250}} />
           <Image 
                source={require('../../assets/img/grediant.png')}
                resizeMode='cover' style={styles.gradientImage} />
            <ContentWidget style={styles.infoContentTwo}>
                <MyAppText style={{color:'white'}}>{data.title}</MyAppText>
            </ContentWidget>
            {this.state.openVideo && <View style={styles.webViewStyle}>
                <WebView style={{height:250}} source={{uri:`${data.video}?autoplay=1`}} fullScreen={true} />
            </View>}
            {loading && <Spinner />}
        </View>
    );
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我有一个playIcon自定义按钮,如果我点击该按钮,那么youtube视频应播放.我不知道代码中哪里出错了.

youtube autoplay react-native

11
推荐指数
1
解决办法
1397
查看次数

UIWebview中的Youtube视频自动播放

我在这个论坛上发现了许多关于嵌入youtube视频和自动播放的问题,但没有一个问题清除我的疑虑.

我找到了两种在UIWebView中嵌入youtube视频的方法

1)

NSString *youTubeHTMLTemplate = @"<html><head><style type=\"text/css\">body { background-color: transparent;color: white;}</style></head><body style=\"margin:0\"><embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" width=\"%0.0f\" height=\"%0.0f\"></embed></body></html>"; 
finalHtml = [NSString stringWithFormat:youTubeHTMLTemplate, fullYopuTubeUrl, htmlFrameWidth, htmlFrameHeight];
Run Code Online (Sandbox Code Playgroud)

2)

NSString *youTubeHTMLTemplate = @"<html><body style=\"margin:0;padding:0;\"><iframe class=\"youtube-player\" type=\"text/html\" width=\"%f\" height=\"%f\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\" allowfullscreen></iframe></body></html>";
finalHtml = [NSString stringWithFormat:youTubeHTMLTemplate, htmlFrameWidth, htmlFrameHeight, videoID];
Run Code Online (Sandbox Code Playgroud)

如果我使用(1)方法并按照这里给出的方法我的视频自动播放.想法是在UIWebView中找到按钮并向其发送触摸事件.

如果我使用(2)并遵循相同的方法,视频不会自动播放.

我认为建议使用(2)方法,因为(1)仅用于Flash视频(对吗?).

无论如何(2)是可能的吗?这个链接说不.

谁能证实

  • 如果我是正确的,建议使用(2)
  • 无法使用(2)进行自动播放.

embed youtube uiwebview autoplay ios

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

autoplay ×2

youtube ×2

audio ×1

embed ×1

html5 ×1

ios ×1

ipad ×1

iphone ×1

react-native ×1

uiwebview ×1