2

私の知る限り、実装で何も変更されていないため、奇妙な問題です。YouTube クリップ プレーヤー (以下のコード) が埋め込まれており、必要なビデオを再生するのに問題なく動作します。しかし、画面を回転させると、ビデオは縦向きモードのままになります。以前は問題なく動作していました。何かご意見は?

- (void)autoplay:(NSString *)youtubeID sender:(UIView *)sender
{

    NSLog(@"%@", [NSString stringWithFormat:@"Youtube ID: %@", youtubeID]);

    // Template for youtube video embedded play
    NSString * htmlTemplate = @"\
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\
    <html><head>\
    <META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\
    <style>body{background:#000;margin:0px}</style>\
    </head>\
    <body>\
    <script type=\"text/javascript\" src=\"http://www.youtube.com/iframe_api\"></script>\
    <script type=\"text/javascript\">\
    var intervalTimer;\
    var ytplayer;\
    var doesPlay = 0;\
    function onYouTubeIframeAPIReady() {\
    ytplayer = new YT.Player('playerId', {\
    playerVars: {'controls': 0},\
    events: {\
    'onReady': onPlayerReady,\
    'onStateChange': onPlayerStateChange,\
    'onError' : onPlayerError\
    }\
    });\
    }\
    function onPlayerReady(event) {\
    event.target.playVideo();\
    }\
    function onPlayerError(event) {\
    window.location.href = \"yidio://failure\";\
    }\
    function onPlayerStateChange(event) {\
    if (event.data == YT.PlayerState.PLAYING)\
    {\
    doesPlay = 1;\
    }\
    else if (event.data == YT.PlayerState.PAUSED)\
    {\
    doesPlay = 0;\
    }\
    else if (event.data == YT.PlayerState.ENDED)\
    {\
    clearInterval(intervalTimer);\
    event.target.destroy();\
    }\
    }\
    intervalTimer = window.setInterval('passPlayedTime()',1000);\
    function passPlayedTime(){\
    if (doesPlay)\
    {\
    window.location.href = \"playedpercentage://\" + ytplayer.getCurrentTime() / ytplayer.getDuration();\
    }\
    }\
    </script>\
    <iframe id=\"playerId\" type=\"text/html\" width=\"160\" height=\"90\"\
    src=\"http://www.youtube.com/embed/%@?vq=hd720&version=3&enablejsapi=1&rel=0&controls=0\"\
    frameborder=\"0\">\
    </body>\
    </html>";

    NSString * htmlString = [NSString stringWithFormat:htmlTemplate, youtubeID];
    UIWebView * embedded = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
    [embedded setDelegate:self];
    [embedded setMediaPlaybackRequiresUserAction:FALSE];
    [embedded setHidden:TRUE];
    [embedded setTag:EMBEDDED_VIEW_TAG];        

    // Add the embedded webview
    [sender addSubview:embedded];
    [embedded loadHTMLString:htmlString baseURL:nil];

        NSError *error = nil;
        [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
        [[AVAudioSession sharedInstance] setActive:YES error:&error];
    }
4

0 に答える 0