当前位置: 首页>>代码示例>>Python>>正文


Python OpenTok.stop_broadcast方法代码示例

本文整理汇总了Python中opentok.OpenTok.stop_broadcast方法的典型用法代码示例。如果您正苦于以下问题:Python OpenTok.stop_broadcast方法的具体用法?Python OpenTok.stop_broadcast怎么用?Python OpenTok.stop_broadcast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opentok.OpenTok的用法示例。


在下文中一共展示了OpenTok.stop_broadcast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OpenTokBroadcastTest

# 需要导入模块: from opentok import OpenTok [as 别名]
# 或者: from opentok.OpenTok import stop_broadcast [as 别名]

#.........这里部分代码省略.........
            'sessionId': '2_MX4xMDBfjE0Mzc2NzY1NDgwMTJ',
            'layout': {
                'type': 'custom',
                'stylesheet': 'the layout stylesheet (only used with type == custom)'
            },
            'maxDuration': 5400,
            'outputs': {
                'rtmp': {
                    'id': 'my-id',
                    'serverUrl': 'rtmp://myserver/myapp',
                    'streamName': 'my-stream-name'
                }
            },
            'resolution': '640x480'
        }

        broadcast = self.opentok.start_broadcast(self.session_id, options)
        validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
        expect(httpretty.last_request().headers[u('user-agent')]).to(contain(
            u('OpenTok-Python-SDK/')+__version__))
        expect(httpretty.last_request().headers[u('content-type')]).to(equal(u('application/json')))
        expect(broadcast).to(be_an(Broadcast))
        expect(broadcast).to(have_property(u('id'), u('1748b7070a81464c9759c46ad10d3734')))
        expect(broadcast).to(have_property(u('sessionId'), u('2_MX4xMDBfjE0Mzc2NzY1NDgwMTJ-TjMzfn4')))
        expect(broadcast).to(have_property(u('projectId'), 100))
        expect(broadcast).to(have_property(u('createdAt'), 1437676551000))
        expect(broadcast).to(have_property(u('updatedAt'), 1437676551000))
        expect(broadcast).to(have_property(u('resolution'), u('640x480')))
        expect(broadcast).to(have_property(u('status'), u('started')))
        expect(list(broadcast.broadcastUrls)).to(have_length(2))
        expect(list(broadcast.broadcastUrls['rtmp'])).to(have_length(2))

    @httpretty.activate
    def test_stop_broadcast(self):
        """
        Test stop_broadcast() method
        """
        broadcast_id = u('1748b7070a81464c9759c46ad10d3734')

        httpretty.register_uri(
            httpretty.POST,
            u('https://api.opentok.com/v2/project/{0}/broadcast/{1}/stop').format(
                self.api_key,
                broadcast_id
            ),
            body=textwrap.dedent(u("""\
                {
                    "id": "1748b7070a81464c9759c46ad10d3734",
                    "sessionId": "2_MX4xMDBfjE0Mzc2NzY1NDgwMTJ-TjMzfn4",
                    "projectId": 100,
                    "createdAt": 1437676551000,
                    "updatedAt": 1437676551000,
                    "resolution": "640x480",
                    "broadcastUrls": null
                }""")),
            status=200,
            content_type=u('application/json')
        )

        broadcast = self.opentok.stop_broadcast(broadcast_id)
        validate_jwt_header(self, httpretty.last_request().headers[u('x-opentok-auth')])
        expect(httpretty.last_request().headers[u('user-agent')]).to(contain(
            u('OpenTok-Python-SDK/')+__version__))
        expect(httpretty.last_request().headers[u('content-type')]).to(equal(u('application/json')))
        expect(broadcast).to(be_an(Broadcast))
        expect(broadcast).to(have_property(u('id'), u('1748b7070a81464c9759c46ad10d3734')))
开发者ID:opentok,项目名称:Opentok-Python-SDK,代码行数:70,代码来源:test_broadcast.py


注:本文中的opentok.OpenTok.stop_broadcast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。