My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Author: Anssi Piirainen, <api@iki.fi>
*
* Copyright (c) 2009-2011 Flowplayer Oy
*
* This file is part of Flowplayer.
*
* Flowplayer is licensed under the GPL v3 license with an
* Additional Term, see http://flowplayer.org/license_gpl.html
*/
package org.flowplayer.sorenson360 {
import com.sorensonmedia.sdk.Sorenson360SDKLibrary;

import fl.video.FLVPlayback;

import flash.events.Event;
import flash.events.NetStatusEvent;
import flash.system.Security;

import org.flowplayer.controller.ClipURLResolver;
import org.flowplayer.controller.StreamProvider;
import org.flowplayer.model.Clip;
import org.flowplayer.model.Plugin;
import org.flowplayer.model.PluginModel;
import org.flowplayer.util.Log;
import org.flowplayer.view.Flowplayer;

public class SorensonURLResolver implements ClipURLResolver, Plugin {
private var log:Log = new Log(this);
private var _failureListener:Function;
private var _successListener:Function;
private var _sorenson:Sorenson360SDKLibrary;
private var _password:String;
private var _clip:Clip;

public function SorensonURLResolver() {
Security.allowDomain("*");
Security.allowInsecureDomain("*");

_sorenson = new Sorenson360SDKLibrary(new FLVPlayback());
_sorenson.addEventListener("GetVideoUrlComplete", onGetVideoUrl);
_sorenson.addEventListener("PasswordRequired", onPasswordRequired);
_sorenson.addEventListener("PasswordIncorrect", onPasswordIncorrect);
_sorenson.addEventListener("PasswordAccepted", onPasswordAccepted);
_sorenson.addEventListener("VideoUnavailable", onVideoUnavailable);
}

public function resolve(provider:StreamProvider, clip:Clip, successListener:Function):void {
log.debug("resolve()");
_clip = clip;
_successListener = successListener;
log.debug("resolving URL for id " + clip.url);
_sorenson.requestVideoUrl(clip.url);
}

private function onPasswordRequired(event:Event):void {
if (! _clip.getCustomProperty("videoPassword")) {
fail("password required");
return;
}
_sorenson.videoPassword = _clip.getCustomProperty("videoPassword") as String;
_sorenson.requestVideoUrl(_clip.url);
}

private function onGetVideoUrl(event:Event):void {
log.debug("resolved video URL '" + event.target.videoUrl + "'");
_clip.setResolvedUrl(this, event.target.videoUrl);
_successListener(_clip);
}

public function set onFailure(listener:Function):void {
log.debug("received failure listener");
_failureListener = listener;
}

public function onConfig(model:PluginModel):void {
model.dispatchOnLoad();
}

public function onLoad(player:Flowplayer):void {
}

public function getDefaultConfig():Object {
return null;
}

public function handeNetStatusEvent(event:NetStatusEvent):Boolean {
return true;
}

private function fail(message:String):void {
log.error("Failed to resolve: " +message);
if (_failureListener != null) {
_failureListener(message);
}
}

private function onVideoUnavailable(event:Event):void {
fail("video not available");
}

private function onPasswordAccepted(event:Event):void {
log.debug("password accepted");
}

private function onPasswordIncorrect(event:Event):void {
log.debug("incorrect password");
}
}
}

Change log

r1318 by anssip on Feb 16, 2011   Diff
changing copyright notice year numbers
Go to: 
Project members, sign in to write a code review

Older revisions

r628 by anssip on Sep 28, 2009   Diff
initial import
All revisions of this file

File info

Size: 3831 bytes, 110 lines
Powered by Google Project Hosting