Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
coherence
compere
Commits
003b261d
Commit
003b261d
authored
Jun 30, 2007
by
Frank Scholz
Browse files
some Maemo adjustments
parent
dd4f9500
Changes
1
Hide whitespace changes
Inline
Side-by-side
media_renderer
View file @
003b261d
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
os
import
os
,
platform
import
random
# Twisted
...
...
@@ -45,7 +45,7 @@ class MainBackground(object):
else
:
self
.
background
.
fill
((
0
,
0
,
0
))
# black
def
clear
S
creen
(
self
):
def
clear
_s
creen
(
self
):
self
.
screen
.
blit
(
self
.
background
,
(
0
,
0
))
def
clear_part
(
self
,
rect
):
...
...
@@ -56,15 +56,17 @@ class MediaRenderer(object):
def
__init__
(
self
,
fullscreen
=
1
):
pygame
.
init
()
bestdepth
=
pygame
.
display
.
mode_ok
(
SCREENRECT
.
size
,
fullscreen
,
SCREENDEPTH
)
self
.
screen
=
pygame
.
display
.
set_mode
(
SCREENRECT
.
size
,
fullscreen
,
bestdepth
)
#pygame.mouse.set_visible(False)
self
.
fullscreen
=
fullscreen
self
.
bestdepth
=
pygame
.
display
.
mode_ok
(
SCREENRECT
.
size
,
fullscreen
,
SCREENDEPTH
)
self
.
screen
=
pygame
.
display
.
set_mode
(
SCREENRECT
.
size
,
fullscreen
,
self
.
bestdepth
)
pygame
.
mouse
.
set_visible
(
False
)
# decorate the game window
pygame
.
display
.
set_caption
(
'Coherence MediaRenderer'
)
self
.
mainbg
=
MainBackground
(
self
.
screen
,
SCREENRECT
)
self
.
mainbg
.
clear
S
creen
()
self
.
mainbg
.
clear
_s
creen
()
config
=
{}
config
[
'logmode'
]
=
'info'
...
...
@@ -83,8 +85,20 @@ class MediaRenderer(object):
self
.
container_watch
=
[]
self
.
image_index
=
0
self
.
displaying
=
None
self
.
current_image
=
None
self
.
client
=
{}
def
toggle_fullscreen
(
self
):
if
self
.
fullscreen
==
1
:
self
.
fullscreen
=
FULLSCREEN
else
:
self
.
fullscreen
=
1
self
.
screen
=
pygame
.
display
.
set_mode
(
SCREENRECT
.
size
,
self
.
fullscreen
,
self
.
bestdepth
)
self
.
mainbg
.
clear_screen
()
self
.
displaying
=
self
.
current_image
.
get_rect
(
center
=
((
self
.
screen
.
get_width
()
/
2
)
-
1
,(
self
.
screen
.
get_height
()
/
2
)
-
1
))
self
.
screen
.
blit
(
self
.
current_image
,
self
.
displaying
)
pygame
.
display
.
flip
()
def
proceed_to_next_image
(
self
):
if
len
(
self
.
images
)
>
0
:
try
:
...
...
@@ -103,14 +117,14 @@ class MediaRenderer(object):
import
StringIO
im
=
Image
.
open
(
StringIO
.
StringIO
(
result
))
size
=
im
.
size
flickr
_image
=
pygame
.
image
.
frombuffer
(
im
.
tostring
(
"raw"
,
"RGB"
),
im
.
size
,
"RGB"
)
self
.
current
_image
=
pygame
.
image
.
frombuffer
(
im
.
tostring
(
"raw"
,
"RGB"
),
im
.
size
,
"RGB"
)
except
ImportError
:
import
tempfile
tmp_fp
,
tmp_path
=
tempfile
.
mkstemp
()
os
.
write
(
tmp_fp
,
result
)
os
.
close
(
tmp_fp
)
flickr
_image
=
pygame
.
image
.
load
(
tmp_path
).
convert
()
size
=
flickr
_image
.
get_size
()
self
.
current
_image
=
pygame
.
image
.
load
(
tmp_path
).
convert
()
size
=
self
.
current
_image
.
get_size
()
os
.
unlink
(
tmp_path
)
if
self
.
displaying
is
not
None
:
...
...
@@ -132,9 +146,9 @@ class MediaRenderer(object):
new_width
=
int
(
float
(
size
[
0
])
*
relation
)
transform
=
(
new_width
,
new_height
)
if
transform
is
not
None
:
flickr
_image
=
pygame
.
transform
.
scale
(
flickr_image
,
transform
)
self
.
displaying
=
flickr
_image
.
get_rect
(
center
=
((
self
.
screen
.
get_width
()
/
2
)
-
1
,(
self
.
screen
.
get_height
()
/
2
)
-
1
))
self
.
screen
.
blit
(
flickr
_image
,
self
.
displaying
)
self
.
current
_image
=
pygame
.
transform
.
scale
(
flickr_image
,
transform
)
self
.
displaying
=
self
.
current
_image
.
get_rect
(
center
=
((
self
.
screen
.
get_width
()
/
2
)
-
1
,(
self
.
screen
.
get_height
()
/
2
)
-
1
))
self
.
screen
.
blit
(
self
.
current
_image
,
self
.
displaying
)
pygame
.
display
.
flip
()
pygame
.
display
.
set_caption
(
'Coherence MediaRenderer - %s'
%
title
)
...
...
@@ -212,13 +226,20 @@ class MediaRenderer(object):
for
event
in
pygame
.
event
.
get
():
#print event
if
(
event
.
type
==
KEYDOWN
and
event
.
key
==
K_F6
):
"""switch between fullscreen and app mode """
if
((
event
.
type
==
KEYDOWN
and
event
.
key
==
K_ESCAPE
)
or
event
.
type
==
QUIT
):
reactor
.
stop
()
def
main
():
MediaRenderer
()
if
platform
.
uname
()[
1
].
startswith
(
'Nokia'
):
fullscreen
=
FULLSCREEN
else
:
fullscreen
=
1
MediaRenderer
(
fullscreen
=
fullscreen
)
reactor
.
run
()
if
__name__
==
'__main__'
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment