すべてのプロダクト
Search
ドキュメントセンター

Object Storage Service:OSS SDK for Javaを使用したLiveChannelsの管理

最終更新日:Feb 23, 2024

このトピックでは、Object Storage Service (OSS) SDK for Javaを使用してLiveChannelsで実行できる一般的な操作について説明します。 たとえば、LiveChannelsを作成、一覧表示、および削除できます。

LiveChannelを作成する

リアルタイムメッセージングプロトコル (RTMP) を使用してオーディオおよびビデオデータをアップロードする前に、PutLiveChannel操作を呼び出してLiveChannelを作成する必要があります。 PutLiveChannelリクエストへの応答には、LiveChannelにストリームを取り込むために使用されるURLと、取り込まれたストリームを再生するために使用されるURLが含まれます。

説明

返されたURLを使用して、ストリームを取り込み、再生できます。 ストリーム取り込みステータスの照会、ストリーム取り込みレコードの照会、ストリーム取り込みの無効化など、返されたLiveChannel名に基づいて操作を実行することもできます。

次のサンプルコードは、LiveChannelを作成する方法の例を示しています。

com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo delをインポートします。*;
java.util.Listをインポートします。impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";

        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);


        try {
            CreateLiveChannelRequest request = new CreateLiveChannelRequest(bucketName、
                    liveChannelName, "desc", LiveChannelStatus.Enabled, new LiveChannelTarget();
            CreateLiveChannelResult result = ossClient.createLiveChannel (リクエスト);

            // 取り込みURLを照会します。 
            リスト <String> publishUrls = result.getPublishUrls();
            for (String item : publishUrls) {
                System.out.println (アイテム);
            }

            // ストリーミングURLを照会します。 
            リスト <String> playUrls = result.getPlayUrls();
            for (String item : playUrls) {
                System.out.println (アイテム);
            }

        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

LiveChannelsのリスト

次のサンプルコードは、LiveChannelsを一覧表示する方法の例を示します。

com.alibaba.fastjson.JSONをインポートします。com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo delをインポートします。*;
impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";

        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
        
        try {
            ListLiveChannelsRequest request = new ListLiveChannelsRequest(bucketName);
            LiveChannelListing liveChannelListing = ossClient.listLiveChannels (リクエスト);
            System.out.println(JSON.toJSONString(liveChannelListing));
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

LiveChannelを削除する

説明
  • クライアントがストリームを取り込んでいるLiveChannelを削除するDeleteLiveChannelリクエストを送信すると、リクエストは失敗します。

  • DeleteLiveChannel操作は、LiveChannelのみを削除し、LiveChannelに取り込まれたストリームによって生成されたファイルは削除しません。

次のサンプルコードは、LiveChannelを削除する方法の例を示しています。

com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo delをインポートします。*;
impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";

        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            LiveChannelGenericRequest request=新しいLiveChannelGenericRequest(bucketName、liveChannelName);
            ossClient.de leteLiveChannel (リクエスト);
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

LiveChannelのステータスを設定する

次のサンプルコードは、LiveChannelのステータスを設定する方法の例を示しています。

com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo delをインポートします。*;
impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";

        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            ossClient.setLiveChannelStatus(bucketName、liveChannelName、LiveChannelStatus.Enabled);
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

LiveChannelの署名付きURLの照会

次のサンプルコードは、LiveChannelの署名付きURLを照会する方法の例を示しています。

com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo delをインポートします。*;
java.util.Listをインポートします。impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";

        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            CreateLiveChannelRequest request = new CreateLiveChannelRequest(bucketName、
                    liveChannelName, "desc", LiveChannelStatus.Enabled, new LiveChannelTarget();
            CreateLiveChannelResult result = ossClient.createLiveChannel (リクエスト);

            // 取り込みURLを照会します。 
            リスト <String> publishUrls = result.getPublishUrls();
            for (String item : publishUrls) {
                // 署名情報を含まない取り込みURLを照会します。 
                System.out.println (アイテム);

                // 署名情報を含む取り込みURLを照会します。 
                LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName、liveChannelName);
                // expiresは、URLの有効期間を指定します。 expiresの値は、UNIX時間形式に続くタイムスタンプです。 この例では、有効期間は1時間に設定されています。 
                long expires = System.currentTimeMillis() / 1000 + 3600;
                // playlistNameは、createLiveChannel操作を呼び出すときのビデオオンデマンド (VOD) プレイリストの名前を指定します。 このパラメーターを指定しない場合、デフォルト値 "playlist.m3u8" が使用されます。 getLiveChannelInfo操作を呼び出して、VODプレイリストの名前を照会することもできます。 
                String signRtmpUrl = ossClient.generateRtmpUri(bucketName, liveChannelName, liveChannelInfo.getTarget().getPlaylistName(), expires);
                System.out.println(signRtmpUrl);
            }

            // ストリーミングURLを照会します。 
            リスト <String> playUrls = result.getPlayUrls();
            for (String item : playUrls) {
                System.out.println (アイテム);
            }
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

LiveChannelのストリーム取り込みステータスの照会

次のサンプルコードは、LiveChannelのストリーム取り込みステータスを照会する方法の例を示しています。

com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo delをインポートします。*;
impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";

        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            LiveChannelStat liveChannelStat = ossClient.getLiveChannelStat(bucketName、liveChannelName);
            System.out.println(liveChannelStat.toString());
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

LiveChannelの設定を照会する

次のサンプルコードは、LiveChannelの設定を照会する方法の例を示しています。

com.alibaba.fastjson.JSONをインポートします。com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo delをインポートします。*;
impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";

        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName、liveChannelName);
            System.out.println(JSON.toJSONString(liveChannelInfo));
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

LiveChannelのVODプレイリストを生成する

PostVodPlaylist操作を呼び出して、特定のLiveChannelのVODプレイリストを生成できます。 OSSは、特定の期間内に指定されたLiveChannelに取り込まれたストリームによって生成されたTSファイルを照会し、ファイルをM3U8プレイリストに収束させます。

次のサンプルコードは、LiveChannelのVODプレイリストを生成する方法の例を示しています。

com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。java.text.DateFormatをインポートします。java.text.ParseExceptionをインポートします。java.text.SimpleDateFormatをインポートします。java.util.Dateをインポートします。impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";
        // プレイリストの名前を指定します。 
        文字列playListName = "yourPlayListName";


        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
        long startTime = getUnixTimestamp("2019-06-27 23:00:00");
        long endTIme = getUnixTimestamp("2019-06-28 22:00:00");
        try {
            ossClient.generateVodPlaylist(bucketName、liveChannelName、playListName、startTime、endTIme);
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }

    private static long getUnixTimestamp(String time) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            日付日付=format.parse(time);
            return date.getTime() / 1000;
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }
}

LiveChannelのプレイリストを照会する

次のサンプルコードは、特定の時間範囲内にLiveChannelに取り込まれたストリームによって生成されたプレイリストを照会する方法の例を示しています。

com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo del.OSSObjectをインポートします。java.text.DateFormatをインポートします。java.text.ParseExceptionをインポートします。java.text.SimpleDateFormatをインポートします。java.util.Dateをインポートします。impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";


        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
        long startTime = getUnixTimestamp("2019-06-27 23:00:00");
        long endTIme = getUnixTimestamp("2019-06-28 22:00:00");
        try {
            OSSObject ossObject = ossClient.getVodPlaylist(bucketName, liveChannelName, startTime, endTIme);
            System.out.println(ossObject.toString());
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }

    private static long getUnixTimestamp(String time) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            日付日付=format.parse(time);
            return date.getTime() / 1000;
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }
}

LiveChannelのストリーム取り込みレコードの照会

GetLiveChannelHistory操作を呼び出して、特定のLiveChannelのストリーム取り込みレコードを照会できます。 GetLiveChannelHistory操作を呼び出して、LiveChannelの最新のストリーム取り込みレコードを最大10個まで照会できます。

次のサンプルコードは、LiveChannelのストリーム取り込みレコードを照会する方法の例を示しています。

com.alibaba.fastjson.JSONをインポートします。com.aliyun.oss.ClientExceptionをインポートします。com.aliyun.oss.OSSをインポートします。com.aliyun.oss.OSSClientBuilderをインポートします。com.aliyun.oss.OSSExceptionをインポートします。com.aliyun.oss.mo del.LiveRecordをインポートします。java.util.Listをインポートします。impor t com.aliyun.oss.com mon.auth.*;

public classデモ {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // 環境変数からアクセス資格情報を取得します。 サンプルコードを実行する前に、OSS_ACCESS_KEY_IDおよびOSS_ACCESS_KEY_SECRET環境変数が設定されていることを確認してください。 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // バケットの名前を指定します。 例: examplebucket. 
        String bucketName = "examplebucket";
        // LiveChannelの名前を指定します。 
        文字列liveChannelName = "yourLiveChannelName";


        // Create an OSSClient instance. 
        OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);

        try {
            List<LiveRecord> list = ossClient.getLiveChannelHistory(bucketName, liveChannelName);
            System.out.println(JSON.toJSONString (リスト));
        } catch (Exception e) {
            oe.printStackTrace();
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "しかし、何らかの理由でエラー応答で拒否されました。");
            System.out.println("エラーメッセージ:" + oe.getErrorMessage());
            System.out.println("エラーコード:" + oe.getErrorCode());
            System.out.println("リクエストID:" + oe.getRequestId());
            System.out.println("ホストID:" + oe.getHostId());
        } catch (ClientException e) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + 「ネットワークにアクセスできないなど」;
            System.out.println("エラーメッセージ:" + ce.getMessage());
        } 最後に{
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

参考資料

  • LiveChannelを作成するために呼び出すことができるAPI操作の詳細については、「PutLiveChannel」をご参照ください。

  • LiveChannelsを一覧表示するために呼び出すAPI操作の詳細については、「ListLiveChannel」をご参照ください。

  • LiveChannelを削除するために呼び出すことができるAPI操作の詳細については、「DeleteLiveChannel」をご参照ください。

  • LiveChannelのステータスを設定するために呼び出すことができるAPI操作の詳細については、「PutLiveChannelStatus」をご参照ください。

  • LiveChannelのストリーム取り込みステータスを照会するために呼び出すことができるAPI操作の詳細については、「GetLiveChannelStat」をご参照ください。

  • LiveChannelの構成を照会するために呼び出すことができるAPI操作の詳細については、「GetLiveChannelInfo」をご参照ください。

  • LiveChannelのプレイリストを生成するために呼び出すAPI操作の詳細については、「PostVodPlaylist」をご参照ください。

  • LiveChannelのプレイリストを照会するために呼び出すAPI操作の詳細については、「GetVodPlaylist」をご参照ください。

  • LiveChannelのストリーム取り込みレコードを照会するために呼び出すことができるAPI操作の詳細については、「GetLiveChannelHistory」をご参照ください。