2017-06-26 6 views
1

「Alexaスキルキット」の「AudioPlayer」を使用して、HLSオーディオ形式のURLをストリーミングしています。 AWS LambdaとDeveloper Portalからエラーは発生していません。サイレントエコー(https://silentecho.bespoken.io/)を使用してテストしています。 AlexaはMP3形式のURLと、私がフォーラムで見つけたいくつかのHLSを再生することができます。しかし、私のHLS URLは機能していません。Alexaスキル:AudioPlayer HLSストリームURLが機能しない

マイHLSのURL:http://cpdc101-lh.akamaihd.net/i/[email protected]/master.m3u8

その他HLSのURL:https://as-hls-ww-live.bbcfmt.hs.llnwd.net/pool_6/live/bbc_radio_fourfm/bbc_radio_fourfm.isml/bbc_radio_fourfm-audio %3d96000.norewind.m3u8

他のHLS URLが再生されていますが、何も聞こえません。それにもかかわらず、私のHLSサイレントエコーでの作業中に、このエラーが発生しました。「要求されたスキルレスポンスに問題がありました。誰も私のHLSリンクとその違いを見ていますか?

このHLS URLを動作させる方法を知る手助けがありますか?

コード:

var lastPlayedByUser = {}; 
 
var streamURL = "http://cpdc101-lh.akamaihd.net/i/[email protected]/master.m3u8"; 
 

 

 
exports.handler = function(event, context) { 
 
    var player = new SidRothPlayer(event, context); 
 
    player.handle(); 
 
}; 
 

 
var SidRothPlayer = function (event, context) { 
 
    this.event = event; 
 
    this.context = context; 
 
}; 
 

 
SidRothPlayer.prototype.handle = function() { 
 
    var requestType = this.event.request.type; 
 
    var userId = this.event.context ? this.event.context.System.user.userId : this.event.session.user.userId; 
 

 
    if (requestType === "LaunchRequest") { 
 
     this.play(streamURL, 0); 
 

 
    } else if (requestType === "IntentRequest") { 
 
     var intent = this.event.request.intent; 
 
     if (intent.name === "Play") { 
 
      this.play(streamURL, 0); 
 

 
     } else if (intent.name === "AMAZON.PauseIntent") { 
 
      this.stop(); 
 

 
     } else if (intent.name === "AMAZON.ResumeIntent") { 
 
      var lastPlayed = this.loadLastPlayed(userId); 
 
      var offsetInMilliseconds = 0; 
 
      if (lastPlayed !== null) { 
 
       offsetInMilliseconds = lastPlayed.request.offsetInMilliseconds; 
 
      } 
 

 
      this.play(streamURL, offsetInMilliseconds); 
 
     } 
 
    } else if (requestType === "AudioPlayer.PlaybackStopped") { 
 
     this.saveLastPlayed(userId, this.event); 
 
     this.context.succeed(true); 
 
    } 
 
}; 
 

 

 
SidRothPlayer.prototype.play = function (audioURL, offsetInMilliseconds) { 
 
    var response = { 
 
     version: "1.0", 
 
     response: { 
 
      shouldEndSession: true, 
 
      directives: [ 
 
       { 
 
        type: "AudioPlayer.Play", 
 
        playBehavior: "REPLACE_ALL", 
 
        audioItem: { 
 
         stream: { 
 
          url: audioURL, 
 
          token: "0", 
 
          expectedPreviousToken: null, 
 
          offsetInMilliseconds: offsetInMilliseconds 
 
         } 
 
        } 
 
       } 
 
      ] 
 
     } 
 
    }; 
 

 
    this.context.succeed(response); 
 
}; 
 

 

 
SidRothPlayer.prototype.stop = function() { 
 
    var response = { 
 
     version: "1.0", 
 
     response: { 
 
      shouldEndSession: true, 
 
      directives: [ 
 
       { 
 
        type: "AudioPlayer.Stop" 
 
       } 
 
      ] 
 
     } 
 
    }; 
 

 
    this.context.succeed(response); 
 
}; 
 

 
SidRothPlayer.prototype.saveLastPlayed = function (userId, lastPlayed) { 
 
    lastPlayedByUser[userId] = lastPlayed; 
 
}; 
 

 
SidRothPlayer.prototype.loadLastPlayed = function (userId) { 
 
    var lastPlayed = null; 
 
    if (userId in lastPlayedByUser) { 
 
     lastPlayed = lastPlayedByUser[userId]; 
 
    } 
 
    return lastPlayed; 
 
};

答えて

1

あなたのストリームのURLがhttpsである必要があります。

0

ありがとうWejd DAGHFOUS。 URLをHTTPSに変更したところ、エラーは消えました。他のHLSリンクのように、私は今再生することができますが、何も聞こえません。

ありがとうございますjoseluismg。 HLSが再生するオーディオのみでなければならないかどうか知っていますか?

+0

私はオーディオのみであると信じている他のHLSをテストしました。彼らはラジオ局です。 VLCで働いていましたが、サイレントエコーで演奏されていません。 その他HLS: - https://c4.prod.playlists.ihrhls.com/3379/playlist.m3u8 - http://radioitaliasmi-lh.akamaihd.net/i/[email protected]/ master.m3u8 - http://radiom2o-lh.akamaihd.net/i/[email protected]/master.m3u8 –

+0

正しい方法は、URLをHTTPSにすることです。超簡単な答え、ありがとうWejd。 –

関連する問題